From aa9aae294e987ac60779b6396d485517fd6cc4b2 Mon Sep 17 00:00:00 2001 From: eriedaberrie Date: Wed, 20 Mar 2024 21:47:04 -0700 Subject: [PATCH 01/45] Fix compile after hyprland header location change --- flake.lock | 101 +++++++++++++++++++++++++++++++++++++++--------- src/Hy3Node.hpp | 2 +- 2 files changed, 84 insertions(+), 19 deletions(-) diff --git a/flake.lock b/flake.lock index 6695ff8..76b1e36 100644 --- a/flake.lock +++ b/flake.lock @@ -1,20 +1,47 @@ { "nodes": { + "hyprcursor": { + "inputs": { + "hyprlang": "hyprlang", + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1710257359, + "narHash": "sha256-43re5pzE/cswFAgw92/ugsB3+d5ufDaCcLtl9ztKfBo=", + "owner": "hyprwm", + "repo": "hyprcursor", + "rev": "1761f6cefd77f4fcd2039d930c88d6716ddc4974", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprcursor", + "type": "github" + } + }, "hyprland": { "inputs": { + "hyprcursor": "hyprcursor", "hyprland-protocols": "hyprland-protocols", - "hyprlang": "hyprlang", + "hyprlang": "hyprlang_2", "nixpkgs": "nixpkgs", - "systems": "systems", + "systems": "systems_2", "wlroots": "wlroots", "xdph": "xdph" }, "locked": { - "lastModified": 1709720053, - "narHash": "sha256-hR0RSeqFOXCggqbGhkFZT3ZAbGc2cAoeeyXU3V5J4hU=", + "lastModified": 1710986113, + "narHash": "sha256-tC6KaJExkSsp7+D7amwjZSYAX347GJC1HYvg3DV0LEI=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "d6f1b151b2fe85ffbb131cbdd05acefc6a357e81", + "rev": "4c796683c05a0eaccc14aae8875f06972f9f3c5e", "type": "github" }, "original": { @@ -49,6 +76,29 @@ } }, "hyprlang": { + "inputs": { + "nixpkgs": [ + "hyprland", + "hyprcursor", + "nixpkgs" + ], + "systems": "systems" + }, + "locked": { + "lastModified": 1709914708, + "narHash": "sha256-bR4o3mynoTa1Wi4ZTjbnsZ6iqVcPGriXp56bZh5UFTk=", + "owner": "hyprwm", + "repo": "hyprlang", + "rev": "a685493fdbeec01ca8ccdf1f3655c044a8ce2fe2", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprlang", + "type": "github" + } + }, + "hyprlang_2": { "inputs": { "nixpkgs": [ "hyprland", @@ -60,11 +110,11 @@ ] }, "locked": { - "lastModified": 1708787654, - "narHash": "sha256-7ACgM3ZuAhPqurXHUvR2nWMRcnmzGGPjLK6q4DSTelI=", + "lastModified": 1709914708, + "narHash": "sha256-bR4o3mynoTa1Wi4ZTjbnsZ6iqVcPGriXp56bZh5UFTk=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "0fce791ba2334aca183f2ed42399518947550d0d", + "rev": "a685493fdbeec01ca8ccdf1f3655c044a8ce2fe2", "type": "github" }, "original": { @@ -75,11 +125,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1708807242, - "narHash": "sha256-sRTRkhMD4delO/hPxxi+XwLqPn8BuUq6nnj4JqLwOu0=", + "lastModified": 1710272261, + "narHash": "sha256-g0bDwXFmTE7uGDOs9HcJsfLFhH7fOsASbAuOzDC+fhQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a", + "rev": "0ad13a6833440b8e238947e47bea7f11071dc2b2", "type": "github" }, "original": { @@ -109,22 +159,37 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + }, "wlroots": { "flake": false, "locked": { "host": "gitlab.freedesktop.org", - "lastModified": 1708558866, - "narHash": "sha256-Mz6hCtommq7RQfcPnxLINigO4RYSNt23HeJHC6mVmWI=", + "lastModified": 1709983277, + "narHash": "sha256-wXWIJLd4F2JZeMaihWVDW/yYXCLEC8OpeNJZg9a9ly8=", "owner": "wlroots", "repo": "wlroots", - "rev": "0cb091f1a2d345f37d2ee445f4ffd04f7f4ec9e5", + "rev": "50eae512d9cecbf0b3b1898bb1f0b40fa05fe19b", "type": "gitlab" }, "original": { "host": "gitlab.freedesktop.org", "owner": "wlroots", "repo": "wlroots", - "rev": "0cb091f1a2d345f37d2ee445f4ffd04f7f4ec9e5", + "rev": "50eae512d9cecbf0b3b1898bb1f0b40fa05fe19b", "type": "gitlab" } }, @@ -148,11 +213,11 @@ ] }, "locked": { - "lastModified": 1708696469, - "narHash": "sha256-shh5wmpeYy3MmsBfkm4f76yPsBDGk6OLYRVG+ARy2F0=", + "lastModified": 1709299639, + "narHash": "sha256-jYqJM5khksLIbqSxCLUUcqEgI+O2LdlSlcMEBs39CAU=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "1b713911c2f12b96c2574474686e4027ac4bf826", + "rev": "2d2fb547178ec025da643db57d40a971507b82fe", "type": "github" }, "original": { diff --git a/src/Hy3Node.hpp b/src/Hy3Node.hpp index f892efb..759feaf 100644 --- a/src/Hy3Node.hpp +++ b/src/Hy3Node.hpp @@ -6,7 +6,7 @@ enum class Hy3GroupLayout; #include -#include +#include #include "Hy3Layout.hpp" #include "TabGroup.hpp" From cc953fc8c0b0c7fedbbc5e4656dae1326b673fdf Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 29 Mar 2024 01:47:50 -0700 Subject: [PATCH 02/45] fixup: fix compile against hyprland main --- flake.lock | 24 ++++++++--------- src/Hy3Layout.hpp | 1 + src/TabGroup.cpp | 68 +++++++++++------------------------------------ 3 files changed, 29 insertions(+), 64 deletions(-) diff --git a/flake.lock b/flake.lock index 977c77c..21cd9cf 100644 --- a/flake.lock +++ b/flake.lock @@ -13,11 +13,11 @@ ] }, "locked": { - "lastModified": 1710257359, - "narHash": "sha256-43re5pzE/cswFAgw92/ugsB3+d5ufDaCcLtl9ztKfBo=", + "lastModified": 1711466786, + "narHash": "sha256-sArxGyUBiCA1in+q6t0QqT+ZJiZ1PyBp7cNPKLmREM0=", "owner": "hyprwm", "repo": "hyprcursor", - "rev": "1761f6cefd77f4fcd2039d930c88d6716ddc4974", + "rev": "d3876f34779cc03ee51e4aafc0d00a4f187c7544", "type": "github" }, "original": { @@ -37,11 +37,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1711070930, - "narHash": "sha256-jKOAO/NlfaTC/OcZkPoT87gsfVqt/+Ye+KcaIv6e2mU=", + "lastModified": 1711673030, + "narHash": "sha256-atpS9c2LR56DIURlDLmuKHGmVQj9Xky2aETGhdTwMKg=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "9bad62b85f179ad2c95c6e7f734768ef060a604b", + "rev": "fcd9d77b642c0cd45cae61cf10ed1924f2e7945b", "type": "github" }, "original": { @@ -110,11 +110,11 @@ ] }, "locked": { - "lastModified": 1709914708, - "narHash": "sha256-bR4o3mynoTa1Wi4ZTjbnsZ6iqVcPGriXp56bZh5UFTk=", + "lastModified": 1711250455, + "narHash": "sha256-LSq1ZsTpeD7xsqvlsepDEelWRDtAhqwetp6PusHXJRo=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "a685493fdbeec01ca8ccdf1f3655c044a8ce2fe2", + "rev": "b3e430f81f3364c5dd1a3cc9995706a4799eb3fa", "type": "github" }, "original": { @@ -125,11 +125,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1710272261, - "narHash": "sha256-g0bDwXFmTE7uGDOs9HcJsfLFhH7fOsASbAuOzDC+fhQ=", + "lastModified": 1711523803, + "narHash": "sha256-UKcYiHWHQynzj6CN/vTcix4yd1eCu1uFdsuarupdCQQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0ad13a6833440b8e238947e47bea7f11071dc2b2", + "rev": "2726f127c15a4cc9810843b96cad73c7eb39e443", "type": "github" }, "original": { diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index 766d0bb..d269229 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -89,6 +89,7 @@ public: virtual void replaceWindowDataWith(CWindow* from, CWindow* to); virtual bool isWindowReachable(CWindow*); virtual void bringWindowToTop(CWindow*); + virtual Vector2D predictSizeForNewWindowTiled() { return Vector2D(); } virtual void onEnable(); virtual void onDisable(); diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 5483683..46651dd 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -11,47 +11,23 @@ #include "globals.hpp" Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_bar), node(node) { - this->focused.create( - 0.0f, - g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"), - nullptr, - AVARDAMAGE_NONE - ); + this->focused + .create(0.0f, g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"), AVARDAMAGE_NONE); - this->urgent.create( - 0.0f, - g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"), - nullptr, - AVARDAMAGE_NONE - ); + this->urgent + .create(0.0f, g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"), AVARDAMAGE_NONE); - this->offset.create( - -1.0f, - g_pConfigManager->getAnimationPropertyConfig("windowsMove"), - nullptr, - AVARDAMAGE_NONE - ); + this->offset + .create(-1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE); - this->width.create( - -1.0f, - g_pConfigManager->getAnimationPropertyConfig("windowsMove"), - nullptr, - AVARDAMAGE_NONE - ); + this->width + .create(-1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE); - this->vertical_pos.create( - 1.0f, - g_pConfigManager->getAnimationPropertyConfig("windowsIn"), - nullptr, - AVARDAMAGE_NONE - ); + this->vertical_pos + .create(1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), AVARDAMAGE_NONE); - this->fade_opacity.create( - 0.0f, - g_pConfigManager->getAnimationPropertyConfig("windowsIn"), - nullptr, - AVARDAMAGE_NONE - ); + this->fade_opacity + .create(0.0f, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), AVARDAMAGE_NONE); this->focused.registerVar(); this->urgent.registerVar(); @@ -271,12 +247,8 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) { } Hy3TabBar::Hy3TabBar() { - this->fade_opacity.create( - 1.0f, - g_pConfigManager->getAnimationPropertyConfig("windowsMove"), - nullptr, - AVARDAMAGE_NONE - ); + this->fade_opacity + .create(1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE); this->fade_opacity.registerVar(); this->fade_opacity.setUpdateCallback([this](void*) { this->dirty = true; }); @@ -423,17 +395,9 @@ void Hy3TabBar::setSize(Vector2D size) { } Hy3TabGroup::Hy3TabGroup(Hy3Node& node) { - this->pos.create( - g_pConfigManager->getAnimationPropertyConfig("windowsMove"), - nullptr, - AVARDAMAGE_NONE - ); + this->pos.create(g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE); - this->size.create( - g_pConfigManager->getAnimationPropertyConfig("windowsMove"), - nullptr, - AVARDAMAGE_NONE - ); + this->size.create(g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE); this->pos.registerVar(); this->size.registerVar(); From 45a6664d7eaa8c7fbfe2adb67cae1e465afce3ba Mon Sep 17 00:00:00 2001 From: Visti Andresen Date: Mon, 1 Apr 2024 18:18:33 +0200 Subject: [PATCH 03/45] Switched to using the new getWorkspaceRulesFor API --- src/Hy3Layout.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index b1f1773..5fc3346 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -1476,7 +1476,7 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { return; } - const auto workspace_rule = g_pConfigManager->getWorkspaceRuleFor(workspace); + const auto workspace_rules = g_pConfigManager->getWorkspaceRulesFor(workspace); // clang-format off static const auto gaps_in = ConfigValue("general:gaps_in"); @@ -1513,7 +1513,14 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { && g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_FULL))) { - window->m_sSpecialRenderData.border = workspace_rule.border.value_or(*no_gaps_when_only == 2); + window->m_sSpecialRenderData.border = *no_gaps_when_only == 2; + for (auto& workspace_rule : workspace_rules) { + if (workspace_rule.border.has_value()) { + //Hyprland src/desktop/Window.cpp, line 1107, SHA 5e8c25d498ed5cb7852ae74a876b0c138a62d59d + //does not break the loop, the last value gets to decide + window->m_sSpecialRenderData.border = workspace_rule.border.value(); + } + } window->m_sSpecialRenderData.rounding = false; window->m_sSpecialRenderData.shadow = false; From 6f9719291386d5e3baad211420d60e54e9967ee6 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 3 Apr 2024 18:16:12 -0700 Subject: [PATCH 04/45] fixup: fix compile against hyprland 0.38.0 --- flake.lock | 7 ++++--- flake.nix | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index 21cd9cf..f3a4c36 100644 --- a/flake.lock +++ b/flake.lock @@ -37,15 +37,16 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1711673030, - "narHash": "sha256-atpS9c2LR56DIURlDLmuKHGmVQj9Xky2aETGhdTwMKg=", + "lastModified": 1711996237, + "narHash": "sha256-oa82eFINs1HkEnx3Nu+GEQQxXXNkJzSci3HZU//OJ2Y=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "fcd9d77b642c0cd45cae61cf10ed1924f2e7945b", + "rev": "3875679755014997776e091ff8903acfb311dd2f", "type": "github" }, "original": { "owner": "hyprwm", + "ref": "v0.38.0", "repo": "Hyprland", "type": "github" } diff --git a/flake.nix b/flake.nix index a375308..f675e78 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "github:hyprwm/Hyprland"; + hyprland.url = "github:hyprwm/Hyprland?ref=v0.38.0"; }; outputs = { self, hyprland, ... }: let From ea9074a2af62d4000a4533aaa0d5d271644933fc Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 3 Apr 2024 18:24:52 -0700 Subject: [PATCH 05/45] version: bump version to hl0.38.0 --- hyprpm.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hyprpm.toml b/hyprpm.toml index 09b5f96..6149783 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -5,7 +5,8 @@ commit_pins = [ ["03ebbe18ed8517ee22591eac82cd54322f42cb7d", "2f28dc810c0e1f42763a1f14fb011c4fce6db8be"], ["84ab8d11e8951a6551d1e1bf87796a8589da6d47", "d3e20856a9896f28b506195b31407eddc6df2e20"], ["1c460e98f870676b15871fe4e5bfeb1a32a3d6d8", "c880e0f00946273ee0304bba9c1de276062d496f"], - ["c5e28ebcfe00a510922779b2c568cfa52a317445", "8ac36f3954619a9a5c1a1bb3296f782452987e82"] + ["c5e28ebcfe00a510922779b2c568cfa52a317445", "8ac36f3954619a9a5c1a1bb3296f782452987e82"], + ["3875679755014997776e091ff8903acfb311dd2f", "6f9719291386d5e3baad211420d60e54e9967ee6"] ] [hy3] From fdc4749ac7010a05ed4cc9f7450dcf93aeb65999 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 3 Apr 2024 21:45:40 -0700 Subject: [PATCH 06/45] fixup: fix breakage from hyprland#5380 --- flake.lock | 7 +- flake.nix | 2 +- src/Hy3Layout.cpp | 163 +++++++++++++++++++++----------------------- src/Hy3Layout.hpp | 37 +++++----- src/Hy3Node.cpp | 11 ++- src/Hy3Node.hpp | 2 +- src/TabGroup.cpp | 12 ++-- src/TabGroup.hpp | 2 +- src/dispatchers.cpp | 64 +++++++++-------- src/globals.hpp | 1 + 10 files changed, 143 insertions(+), 158 deletions(-) diff --git a/flake.lock b/flake.lock index f3a4c36..ce30305 100644 --- a/flake.lock +++ b/flake.lock @@ -37,16 +37,15 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1711996237, - "narHash": "sha256-oa82eFINs1HkEnx3Nu+GEQQxXXNkJzSci3HZU//OJ2Y=", + "lastModified": 1712189807, + "narHash": "sha256-hmEBPDk1GbpPzpa0gLhJ0XJ5rvt+dMddKNQGr9J8XyA=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "3875679755014997776e091ff8903acfb311dd2f", + "rev": "b7d71bc0e1084bc1a296ae906503709a74fde4d9", "type": "github" }, "original": { "owner": "hyprwm", - "ref": "v0.38.0", "repo": "Hyprland", "type": "github" } diff --git a/flake.nix b/flake.nix index f675e78..a375308 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "github:hyprwm/Hyprland?ref=v0.38.0"; + hyprland.url = "github:hyprwm/Hyprland"; }; outputs = { self, hyprland, ... }: let diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 5fc3346..a1f54a0 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -36,7 +37,7 @@ bool performContainment(Hy3Node& node, bool contained, CWindow* window) { node.layout->nodes.push_back({ .parent = &node, .data = window, - .workspace_id = node.workspace_id, + .workspace = node.workspace, .layout = node.layout, }); @@ -78,7 +79,7 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) { (uintptr_t) window, window->m_bIsFloating, window->m_iMonitorID, - window->m_iWorkspaceID + window->m_pWorkspace->m_iID ); if (window->m_bIsFloating) return; @@ -97,7 +98,7 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) { this->nodes.push_back({ .parent = nullptr, .data = window, - .workspace_id = window->m_iWorkspaceID, + .workspace = window->m_pWorkspace, .layout = this, }); @@ -115,26 +116,24 @@ void Hy3Layout::insertNode(Hy3Node& node) { return; } - auto* workspace = g_pCompositor->getWorkspaceByID(node.workspace_id); - - if (workspace == nullptr) { + if (!valid(node.workspace)) { hy3_log( ERR, "insertNode called for node {:x} with invalid workspace id {}", (uintptr_t) &node, - node.workspace_id + node.workspace->m_iID ); return; } node.reparenting = true; - auto* monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID); + auto* monitor = g_pCompositor->getMonitorFromID(node.workspace->m_iMonitorID); Hy3Node* opening_into; Hy3Node* opening_after = nullptr; - auto* root = this->getWorkspaceRootGroup(node.workspace_id); + auto* root = this->getWorkspaceRootGroup(node.workspace); if (root != nullptr) { opening_after = root->getFocusedNode(); @@ -148,7 +147,7 @@ void Hy3Layout::insertNode(Hy3Node& node) { if (opening_after == nullptr) { if (g_pCompositor->m_pLastWindow != nullptr - && g_pCompositor->m_pLastWindow->m_iWorkspaceID == node.workspace_id + && g_pCompositor->m_pLastWindow->m_pWorkspace == node.workspace && !g_pCompositor->m_pLastWindow->m_bIsFloating && (node.data.type == Hy3NodeType::Window || g_pCompositor->m_pLastWindow != node.data.as_window) @@ -161,7 +160,7 @@ void Hy3Layout::insertNode(Hy3Node& node) { RESERVED_EXTENTS | INPUT_EXTENTS ); - if (mouse_window != nullptr && mouse_window->m_iWorkspaceID == node.workspace_id) { + if (mouse_window != nullptr && mouse_window->m_pWorkspace == node.workspace) { opening_after = this->getNodeFromWindow(mouse_window); } } @@ -178,7 +177,7 @@ void Hy3Layout::insertNode(Hy3Node& node) { if (opening_after != nullptr) { opening_into = opening_after->parent; } else { - if ((opening_into = this->getWorkspaceRootGroup(node.workspace_id)) == nullptr) { + if ((opening_into = this->getWorkspaceRootGroup(node.workspace)) == nullptr) { static const auto tab_first_window = ConfigValue("plugin:hy3:tab_first_window"); @@ -191,7 +190,7 @@ void Hy3Layout::insertNode(Hy3Node& node) { .data = height > width ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH, .position = monitor->vecPosition + monitor->vecReservedTopLeft, .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, - .workspace_id = node.workspace_id, + .workspace = node.workspace, .layout = this, }); @@ -203,7 +202,7 @@ void Hy3Layout::insertNode(Hy3Node& node) { .data = Hy3GroupLayout::Tabbed, .position = parent.position, .size = parent.size, - .workspace_id = node.workspace_id, + .workspace = node.workspace, .layout = this, }); @@ -220,14 +219,14 @@ void Hy3Layout::insertNode(Hy3Node& node) { return; } - if (opening_into->workspace_id != node.workspace_id) { + if (opening_into->workspace != node.workspace) { hy3_log( WARN, "opening_into node ({:x}) is on workspace {} which does not match the new window " "(workspace {})", (uintptr_t) opening_into, - opening_into->workspace_id, - node.workspace_id + opening_into->workspace->m_iID, + node.workspace->m_iID ); } @@ -244,7 +243,7 @@ void Hy3Layout::insertNode(Hy3Node& node) { auto& target_group = opening_into->data.as_group; if (*at_enable && opening_after != nullptr && target_group.children.size() > 1 && target_group.layout != Hy3GroupLayout::Tabbed - && this->shouldAutotileWorkspace(opening_into->workspace_id)) + && this->shouldAutotileWorkspace(opening_into->workspace)) { auto is_horizontal = target_group.layout == Hy3GroupLayout::SplitH; auto trigger = is_horizontal ? *at_trigger_width : *at_trigger_height; @@ -380,7 +379,7 @@ void Hy3Layout::recalculateMonitor(const int& monitor_id) { top_node->recalcSizePosRecursive(); } - top_node = this->getWorkspaceRootGroup(monitor->specialWorkspaceID); + top_node = this->getWorkspaceRootGroup(monitor->activeSpecialWorkspace); if (top_node != nullptr) { top_node->position = monitor->vecPosition + monitor->vecReservedTopLeft; @@ -500,15 +499,14 @@ void Hy3Layout::fullscreenRequestForWindow( bool on ) { if (!g_pCompositor->windowValidMapped(window)) return; - if (on == window->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID)) + if (on == window->m_bIsFullscreen || window->m_pWorkspace->m_bIsSpecialWorkspace) return; const auto monitor = g_pCompositor->getMonitorFromID(window->m_iMonitorID); - const auto workspace = g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID); - if (workspace->m_bHasFullscreenWindow && on) return; + if (window->m_pWorkspace->m_bHasFullscreenWindow && on) return; window->m_bIsFullscreen = on; - workspace->m_bHasFullscreenWindow = !workspace->m_bHasFullscreenWindow; + window->m_pWorkspace->m_bHasFullscreenWindow = !window->m_pWorkspace->m_bHasFullscreenWindow; if (!window->m_bIsFullscreen) { auto* node = this->getNodeFromWindow(window); @@ -526,7 +524,7 @@ void Hy3Layout::fullscreenRequestForWindow( window->m_sSpecialRenderData.decorate = true; } } else { - workspace->m_efFullscreenMode = fullscreen_mode; + window->m_pWorkspace->m_efFullscreenMode = fullscreen_mode; // save position and size if floating if (window->m_bIsFloating) { @@ -565,7 +563,7 @@ void Hy3Layout::fullscreenRequestForWindow( .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, .gap_topleft_offset = gap_pos_offset, .gap_bottomright_offset = gap_size_offset, - .workspace_id = window->m_iWorkspaceID, + .workspace = window->m_pWorkspace, }; this->applyNodeDataToWindow(&fakeNode); @@ -628,17 +626,15 @@ void Hy3Layout::alterSplitRatio(CWindow* pWindow, float delta, bool exact) { std::string Hy3Layout::getLayoutName() { return "hy3"; } CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) { - auto* workspace = g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID); - - if (workspace->m_bHasFullscreenWindow) { - return g_pCompositor->getFullscreenWindowOnWorkspace(window->m_iWorkspaceID); + if (window->m_pWorkspace->m_bHasFullscreenWindow) { + return g_pCompositor->getFullscreenWindowOnWorkspace(window->m_pWorkspace->m_iID); } // return the first floating window on the same workspace that has not asked not to be focused if (window->m_bIsFloating) { for (auto& w: g_pCompositor->m_vWindows | std::views::reverse) { if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 - && w->m_iWorkspaceID == window->m_iWorkspaceID && !w->m_bX11ShouldntFocus + && w->m_pWorkspace == window->m_pWorkspace && !w->m_bX11ShouldntFocus && !w->m_sAdditionalConfigData.noFocus && w.get() != window) { return w.get(); @@ -646,7 +642,7 @@ CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) { } } - auto* node = this->getWorkspaceFocusedNode(window->m_iWorkspaceID, true); + auto* node = this->getWorkspaceFocusedNode(window->m_pWorkspace, true); if (node == nullptr) return nullptr; switch (node->data.type) { @@ -706,7 +702,7 @@ void Hy3Layout::onDisable() { } void Hy3Layout::makeGroupOnWorkspace( - int workspace, + const PHLWORKSPACE& workspace, Hy3GroupLayout layout, GroupEphemeralityOption ephemeral ) { @@ -714,40 +710,40 @@ void Hy3Layout::makeGroupOnWorkspace( this->makeGroupOn(node, layout, ephemeral); } -void Hy3Layout::makeOppositeGroupOnWorkspace(int workspace, GroupEphemeralityOption ephemeral) { +void Hy3Layout::makeOppositeGroupOnWorkspace(const PHLWORKSPACE& workspace, GroupEphemeralityOption ephemeral) { auto* node = this->getWorkspaceFocusedNode(workspace); this->makeOppositeGroupOn(node, ephemeral); } -void Hy3Layout::changeGroupOnWorkspace(int workspace, Hy3GroupLayout layout) { +void Hy3Layout::changeGroupOnWorkspace(const PHLWORKSPACE& workspace, Hy3GroupLayout layout) { auto* node = this->getWorkspaceFocusedNode(workspace); if (node == nullptr) return; this->changeGroupOn(*node, layout); } -void Hy3Layout::untabGroupOnWorkspace(int workspace) { +void Hy3Layout::untabGroupOnWorkspace(const PHLWORKSPACE& workspace) { auto* node = this->getWorkspaceFocusedNode(workspace); if (node == nullptr) return; this->untabGroupOn(*node); } -void Hy3Layout::toggleTabGroupOnWorkspace(int workspace) { +void Hy3Layout::toggleTabGroupOnWorkspace(const PHLWORKSPACE& workspace) { auto* node = this->getWorkspaceFocusedNode(workspace); if (node == nullptr) return; this->toggleTabGroupOn(*node); } -void Hy3Layout::changeGroupToOppositeOnWorkspace(int workspace) { +void Hy3Layout::changeGroupToOppositeOnWorkspace(const PHLWORKSPACE& workspace) { auto* node = this->getWorkspaceFocusedNode(workspace); if (node == nullptr) return; this->changeGroupToOppositeOn(*node); } -void Hy3Layout::changeGroupEphemeralityOnWorkspace(int workspace, bool ephemeral) { +void Hy3Layout::changeGroupEphemeralityOnWorkspace(const PHLWORKSPACE& workspace, bool ephemeral) { auto* node = this->getWorkspaceFocusedNode(workspace); if (node == nullptr) return; @@ -868,19 +864,18 @@ void Hy3Layout::shiftNode(Hy3Node& node, ShiftDirection direction, bool once, bo } } -void Hy3Layout::shiftWindow(int workspace, ShiftDirection direction, bool once, bool visible) { +void Hy3Layout::shiftWindow(const PHLWORKSPACE& workspace, ShiftDirection direction, bool once, bool visible) { auto* node = this->getWorkspaceFocusedNode(workspace); if (node == nullptr) return; this->shiftNode(*node, direction, once, visible); } -void Hy3Layout::shiftFocus(int workspace, ShiftDirection direction, bool visible) { +void Hy3Layout::shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection direction, bool visible) { auto* current_window = g_pCompositor->m_pLastWindow; if (current_window != nullptr) { - auto* p_workspace = g_pCompositor->getWorkspaceByID(current_window->m_iWorkspaceID); - if (p_workspace->m_bHasFullscreenWindow) return; + if (current_window->m_pWorkspace->m_bHasFullscreenWindow) return; if (current_window->m_bIsFloating) { auto* next_window = g_pCompositor->getWindowInDirection( @@ -908,12 +903,12 @@ void Hy3Layout::shiftFocus(int workspace, ShiftDirection direction, bool visible } } -void changeNodeWorkspaceRecursive(Hy3Node& node, CWorkspace* workspace) { - node.workspace_id = workspace->m_iID; +void changeNodeWorkspaceRecursive(Hy3Node& node, const PHLWORKSPACE& workspace) { + node.workspace = workspace; if (node.data.type == Hy3NodeType::Window) { auto* window = node.data.as_window; - window->moveToWorkspace(workspace->m_iID); + window->moveToWorkspace(workspace); window->updateToplevel(); window->updateDynamicRules(); } else { @@ -923,42 +918,39 @@ void changeNodeWorkspaceRecursive(Hy3Node& node, CWorkspace* workspace) { } } -void Hy3Layout::moveNodeToWorkspace(int origin, std::string wsname, bool follow) { +void Hy3Layout::moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsname, bool follow) { std::string target_name; - auto target = getWorkspaceIDFromString(wsname, target_name); + auto target_id = getWorkspaceIDFromString(wsname, target_name); - if (target == WORKSPACE_INVALID) { + if (target_id == WORKSPACE_INVALID) { hy3_log(ERR, "moveNodeToWorkspace called with invalid workspace {}", wsname); return; } - if (origin == target) return; + auto workspace = g_pCompositor->getWorkspaceByID(target_id); + + if (origin == workspace) return; auto* node = this->getWorkspaceFocusedNode(origin); auto* focused_window = g_pCompositor->m_pLastWindow; auto* focused_window_node = this->getNodeFromWindow(focused_window); - auto* workspace = g_pCompositor->getWorkspaceByID(target); + auto origin_ws = node != nullptr ? node->workspace + : focused_window != nullptr ? focused_window->m_pWorkspace + : nullptr; - auto wsid = node != nullptr ? node->workspace_id - : focused_window != nullptr ? focused_window->m_iWorkspaceID - : WORKSPACE_INVALID; - - if (wsid == WORKSPACE_INVALID) return; - - auto* origin_ws = g_pCompositor->getWorkspaceByID(wsid); + if (!valid(origin_ws)) return; if (workspace == nullptr) { - hy3_log(LOG, "creating target workspace {} for node move", target); + hy3_log(LOG, "creating target workspace {} for node move", target_id); - workspace = g_pCompositor->createNewWorkspace(target, origin_ws->m_iMonitorID, target_name); + workspace = g_pCompositor->createNewWorkspace(target_id, origin_ws->m_iMonitorID, target_name); } // floating or fullscreen if (focused_window != nullptr && (focused_window_node == nullptr || focused_window->m_bIsFullscreen)) { - hy3_log(LOG, "{:x}, {:x}", (uintptr_t) focused_window, (uintptr_t) workspace); g_pCompositor->moveWindowToWorkspaceSafe(focused_window, workspace); } else { if (node == nullptr) return; @@ -967,8 +959,8 @@ void Hy3Layout::moveNodeToWorkspace(int origin, std::string wsname, bool follow) LOG, "moving node {:x} from workspace {} to workspace {} (follow: {})", (uintptr_t) node, - origin, - target, + origin->m_iID, + workspace->m_iID, follow ); @@ -997,7 +989,7 @@ void Hy3Layout::moveNodeToWorkspace(int origin, std::string wsname, bool follow) } } -void Hy3Layout::changeFocus(int workspace, FocusShift shift) { +void Hy3Layout::changeFocus(const PHLWORKSPACE& workspace, FocusShift shift) { auto* node = this->getWorkspaceFocusedNode(workspace); if (node == nullptr) return; @@ -1117,7 +1109,7 @@ Hy3Node* findTabBarAt(Hy3Node& node, Vector2D pos, Hy3Node** focused_node) { } void Hy3Layout::focusTab( - int workspace, + const PHLWORKSPACE& workspace, TabFocus target, TabFocusMousePriority mouse, bool wrap_scroll, @@ -1209,7 +1201,7 @@ hastab: tab_node->recalcSizePosRecursive(); } -void Hy3Layout::setNodeSwallow(int workspace, SetSwallowOption option) { +void Hy3Layout::setNodeSwallow(const PHLWORKSPACE& workspace, SetSwallowOption option) { auto* node = this->getWorkspaceFocusedNode(workspace); if (node == nullptr || node->parent == nullptr) return; @@ -1221,7 +1213,7 @@ void Hy3Layout::setNodeSwallow(int workspace, SetSwallowOption option) { } } -void Hy3Layout::killFocusedNode(int workspace) { +void Hy3Layout::killFocusedNode(const PHLWORKSPACE& workspace) { if (g_pCompositor->m_pLastWindow != nullptr && g_pCompositor->m_pLastWindow->m_bIsFloating) { g_pCompositor->closeWindow(g_pCompositor->m_pLastWindow); } else { @@ -1238,11 +1230,10 @@ void Hy3Layout::killFocusedNode(int workspace) { } } -void Hy3Layout::expand(int workspace_id, ExpandOption option, ExpandFullscreenOption fs_option) { - auto* node = this->getWorkspaceFocusedNode(workspace_id, false, true); +void Hy3Layout::expand(const PHLWORKSPACE& workspace, ExpandOption option, ExpandFullscreenOption fs_option) { + auto* node = this->getWorkspaceFocusedNode(workspace, false, true); if (node == nullptr) return; - const auto workspace = g_pCompositor->getWorkspaceByID(workspace_id); const auto monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID); switch (option) { @@ -1300,7 +1291,7 @@ void Hy3Layout::expand(int workspace_id, ExpandOption option, ExpandFullscreenOp fullscreen: if (node->data.type != Hy3NodeType::Window) return; window = node->data.as_window; - if (!window->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID)) return; + if (!window->m_bIsFullscreen || window->m_pWorkspace->m_bIsSpecialWorkspace) return; if (workspace->m_bHasFullscreenWindow) return; @@ -1325,7 +1316,7 @@ fsupdate: bool Hy3Layout::shouldRenderSelected(CWindow* window) { if (window == nullptr) return false; - auto* root = this->getWorkspaceRootGroup(window->m_iWorkspaceID); + auto* root = this->getWorkspaceRootGroup(window->m_pWorkspace); if (root == nullptr || root->data.as_group.focused_child == nullptr) return false; auto* focused = root->getFocusedNode(); if (focused == nullptr @@ -1344,9 +1335,9 @@ bool Hy3Layout::shouldRenderSelected(CWindow* window) { } } -Hy3Node* Hy3Layout::getWorkspaceRootGroup(const int& workspace) { +Hy3Node* Hy3Layout::getWorkspaceRootGroup(const PHLWORKSPACE& workspace) { for (auto& node: this->nodes) { - if (node.workspace_id == workspace && node.parent == nullptr + if (node.workspace == workspace && node.parent == nullptr && node.data.type == Hy3NodeType::Group && !node.reparenting) { return &node; @@ -1357,7 +1348,7 @@ Hy3Node* Hy3Layout::getWorkspaceRootGroup(const int& workspace) { } Hy3Node* Hy3Layout::getWorkspaceFocusedNode( - const int& workspace, + const PHLWORKSPACE& workspace, bool ignore_group_focus, bool stop_at_expanded ) { @@ -1449,21 +1440,19 @@ Hy3Node* Hy3Layout::getNodeFromWindow(CWindow* window) { void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { if (node->data.type != Hy3NodeType::Window) return; auto* window = node->data.as_window; - auto root_node = this->getWorkspaceRootGroup(window->m_iWorkspaceID); + auto root_node = this->getWorkspaceRootGroup(window->m_pWorkspace); CMonitor* monitor = nullptr; - auto* workspace = g_pCompositor->getWorkspaceByID(node->workspace_id); - - if (g_pCompositor->isWorkspaceSpecial(node->workspace_id)) { + if (node->workspace->m_bIsSpecialWorkspace) { for (auto& m: g_pCompositor->m_vMonitors) { - if (m->specialWorkspaceID == node->workspace_id) { + if (m->activeSpecialWorkspace == node->workspace) { monitor = m.get(); break; } } } else { - monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID); + monitor = g_pCompositor->getMonitorFromID(node->workspace->m_iMonitorID); } if (monitor == nullptr) { @@ -1476,7 +1465,7 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { return; } - const auto workspace_rules = g_pConfigManager->getWorkspaceRulesFor(workspace); + const auto workspace_rules = g_pConfigManager->getWorkspaceRulesFor(node->workspace); // clang-format off static const auto gaps_in = ConfigValue("general:gaps_in"); @@ -1507,10 +1496,10 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { auto only_node = root_node != nullptr && root_node->data.as_group.children.size() == 1 && root_node->data.as_group.children.front()->data.type == Hy3NodeType::Window; - if (!g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID) + if (!window->m_pWorkspace->m_bIsSpecialWorkspace && ((*no_gaps_when_only != 0 && (only_node || window->m_bIsFullscreen)) || (window->m_bIsFullscreen - && g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID)->m_efFullscreenMode + && window->m_pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL))) { window->m_sSpecialRenderData.border = *no_gaps_when_only == 2; @@ -1640,7 +1629,7 @@ Hy3Node* Hy3Layout::shiftOrGetFocus( .data = shiftIsVertical(direction) ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH, .position = break_parent->position, .size = break_parent->size, - .workspace_id = break_parent->workspace_id, + .workspace = break_parent->workspace, .layout = this, }); @@ -1848,10 +1837,10 @@ void Hy3Layout::updateAutotileWorkspaces() { } } -bool Hy3Layout::shouldAutotileWorkspace(int workspace_id) { +bool Hy3Layout::shouldAutotileWorkspace(const PHLWORKSPACE& workspace) { if (this->autotile.workspace_blacklist) { - return !this->autotile.workspaces.contains(workspace_id); + return !this->autotile.workspaces.contains(workspace->m_iID); } else { - return this->autotile.workspaces.empty() || this->autotile.workspaces.contains(workspace_id); + return this->autotile.workspaces.empty() || this->autotile.workspaces.contains(workspace->m_iID); } } diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index d269229..93333c3 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -1,5 +1,6 @@ #pragma once +#include class Hy3Layout; enum class GroupEphemeralityOption { @@ -95,13 +96,13 @@ public: virtual void onDisable(); void insertNode(Hy3Node& node); - void makeGroupOnWorkspace(int workspace, Hy3GroupLayout, GroupEphemeralityOption); - void makeOppositeGroupOnWorkspace(int workspace, GroupEphemeralityOption); - void changeGroupOnWorkspace(int workspace, Hy3GroupLayout); - void untabGroupOnWorkspace(int workspace); - void toggleTabGroupOnWorkspace(int workspace); - void changeGroupToOppositeOnWorkspace(int workspace); - void changeGroupEphemeralityOnWorkspace(int workspace, bool ephemeral); + void makeGroupOnWorkspace(const PHLWORKSPACE& workspace, Hy3GroupLayout, GroupEphemeralityOption); + void makeOppositeGroupOnWorkspace(const PHLWORKSPACE& workspace, GroupEphemeralityOption); + void changeGroupOnWorkspace(const PHLWORKSPACE& workspace, Hy3GroupLayout); + void untabGroupOnWorkspace(const PHLWORKSPACE& workspace); + void toggleTabGroupOnWorkspace(const PHLWORKSPACE& workspace); + void changeGroupToOppositeOnWorkspace(const PHLWORKSPACE& workspace); + void changeGroupEphemeralityOnWorkspace(const PHLWORKSPACE& workspace, bool ephemeral); void makeGroupOn(Hy3Node*, Hy3GroupLayout, GroupEphemeralityOption); void makeOppositeGroupOn(Hy3Node*, GroupEphemeralityOption); void changeGroupOn(Hy3Node&, Hy3GroupLayout); @@ -110,20 +111,20 @@ public: void changeGroupToOppositeOn(Hy3Node&); void changeGroupEphemeralityOn(Hy3Node&, bool ephemeral); void shiftNode(Hy3Node&, ShiftDirection, bool once, bool visible); - void shiftWindow(int workspace, ShiftDirection, bool once, bool visible); - void shiftFocus(int workspace, ShiftDirection, bool visible); - void moveNodeToWorkspace(int origin, std::string wsname, bool follow); - void changeFocus(int workspace, FocusShift); - void focusTab(int workspace, TabFocus target, TabFocusMousePriority, bool wrap_scroll, int index); - void setNodeSwallow(int workspace, SetSwallowOption); - void killFocusedNode(int workspace); - void expand(int workspace, ExpandOption, ExpandFullscreenOption); + void shiftWindow(const PHLWORKSPACE& workspace, ShiftDirection, bool once, bool visible); + void shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection, bool visible); + void moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsname, bool follow); + void changeFocus(const PHLWORKSPACE& workspace, FocusShift); + void focusTab(const PHLWORKSPACE& workspace, TabFocus target, TabFocusMousePriority, bool wrap_scroll, int index); + void setNodeSwallow(const PHLWORKSPACE& workspace, SetSwallowOption); + void killFocusedNode(const PHLWORKSPACE& workspace); + void expand(const PHLWORKSPACE& workspace, ExpandOption, ExpandFullscreenOption); bool shouldRenderSelected(CWindow*); - Hy3Node* getWorkspaceRootGroup(const int& workspace); + Hy3Node* getWorkspaceRootGroup(const PHLWORKSPACE& workspace); Hy3Node* getWorkspaceFocusedNode( - const int& workspace, + const PHLWORKSPACE& workspace, bool ignore_group_focus = false, bool stop_at_expanded = false ); @@ -146,7 +147,7 @@ private: Hy3Node* shiftOrGetFocus(Hy3Node&, ShiftDirection, bool shift, bool once, bool visible); void updateAutotileWorkspaces(); - bool shouldAutotileWorkspace(int); + bool shouldAutotileWorkspace(const PHLWORKSPACE& workspace); void resizeNode(Hy3Node*, Vector2D, ShiftDirection resize_edge_x, ShiftDirection resize_edge_y); struct { diff --git a/src/Hy3Node.cpp b/src/Hy3Node.cpp index 5eed0fc..9572d7b 100644 --- a/src/Hy3Node.cpp +++ b/src/Hy3Node.cpp @@ -290,10 +290,9 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { // clang-format on if (this->data.type == Hy3NodeType::Window && this->data.as_window->m_bIsFullscreen) { - auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id); - auto* monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID); + auto* monitor = g_pCompositor->getMonitorFromID(this->workspace->m_iMonitorID); - if (workspace->m_efFullscreenMode == FULLSCREEN_FULL) { + if (this->workspace->m_efFullscreenMode == FULLSCREEN_FULL) { this->data.as_window->m_vRealPosition = monitor->vecPosition; this->data.as_window->m_vRealSize = monitor->vecSize; return; @@ -305,7 +304,7 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, .gap_topleft_offset = gap_topleft_offset, .gap_bottomright_offset = gap_bottomright_offset, - .workspace_id = this->workspace_id, + .workspace = this->workspace, }; this->layout->applyNodeDataToWindow(&fake_node); @@ -522,7 +521,7 @@ void Hy3Node::updateTabBar(bool no_animation) { FindTopWindowInNodeResult result; findTopWindowInNode(*this, result); group.tab_bar->target_window = result.window; - if (result.window != nullptr) group.tab_bar->workspace_id = result.window->m_iWorkspaceID; + if (result.window != nullptr) group.tab_bar->workspace = result.window->m_pWorkspace; } else if (group.tab_bar != nullptr) { group.tab_bar->bar.beginDestroy(); group.tab_bar = nullptr; @@ -771,7 +770,7 @@ Hy3Node* Hy3Node::intoGroup(Hy3GroupLayout layout, GroupEphemeralityOption ephem this->layout->nodes.push_back({ .parent = this, .data = layout, - .workspace_id = this->workspace_id, + .workspace = this->workspace, .layout = this->layout, }); diff --git a/src/Hy3Node.hpp b/src/Hy3Node.hpp index 759feaf..772d01f 100644 --- a/src/Hy3Node.hpp +++ b/src/Hy3Node.hpp @@ -87,7 +87,7 @@ struct Hy3Node { Vector2D gap_topleft_offset; Vector2D gap_bottomright_offset; float size_ratio = 1.0; - int workspace_id = -1; + PHLWORKSPACE workspace = nullptr; bool hidden = false; Hy3Layout* layout = nullptr; diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 46651dd..08fe876 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -444,12 +444,11 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { void Hy3TabGroup::tick() { static const auto enter_from_top = ConfigValue("plugin:hy3:tabs:from_top"); static const auto padding = ConfigValue("plugin:hy3:tabs:padding"); - auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id); this->bar.tick(); - if (workspace != nullptr) { - if (workspace->m_bHasFullscreenWindow) { + if (valid(this->workspace)) { + if (this->workspace->m_bHasFullscreenWindow) { if (this->bar.fade_opacity.goal() != 0.0) this->bar.fade_opacity = 0.0; } else { if (this->bar.fade_opacity.goal() != 1.0) this->bar.fade_opacity = 1.0; @@ -489,15 +488,14 @@ void Hy3TabGroup::renderTabBar() { static const auto padding = ConfigValue("plugin:hy3:tabs:padding"); auto* monitor = g_pHyprOpenGL->m_RenderData.pMonitor; - auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id); auto scale = monitor->scale; auto monitor_size = monitor->vecSize; auto pos = this->pos.value() - monitor->vecPosition; auto size = this->size.value(); - if (workspace != nullptr) { - pos = pos + workspace->m_vRenderOffset.value(); + if (valid(this->workspace)) { + pos = pos + this->workspace->m_vRenderOffset.value(); } auto scaled_pos = Vector2D(std::round(pos.x * scale), std::round(pos.y * scale)); @@ -563,7 +561,7 @@ void Hy3TabGroup::renderTabBar() { } auto fade_opacity = - this->bar.fade_opacity.value() * (workspace == nullptr ? 1.0 : workspace->m_fAlpha.value()); + this->bar.fade_opacity.value() * (valid(this->workspace) ? this->workspace->m_fAlpha.value() : 1.0); auto render_entry = [&](Hy3TabBarEntry& entry) { Vector2D entry_pos = { diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 77f7874..3d77624 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -86,7 +86,7 @@ private: class Hy3TabGroup { public: CWindow* target_window = nullptr; - int workspace_id = -1; + PHLWORKSPACE workspace = nullptr; bool hidden = false; Hy3TabBar bar; CAnimatedVariable pos; diff --git a/src/dispatchers.cpp b/src/dispatchers.cpp index 667b1cf..843b17a 100644 --- a/src/dispatchers.cpp +++ b/src/dispatchers.cpp @@ -1,27 +1,26 @@ #include #include +#include #include #include "dispatchers.hpp" #include "globals.hpp" -int workspace_for_action(bool allow_fullscreen = false) { - if (g_pLayoutManager->getCurrentLayout() != g_Hy3Layout.get()) return -1; +PHLWORKSPACE workspace_for_action(bool allow_fullscreen = false) { + if (g_pLayoutManager->getCurrentLayout() != g_Hy3Layout.get()) return nullptr; - int workspace_id = g_pCompositor->m_pLastMonitor->activeWorkspace; + auto workspace = g_pCompositor->m_pLastMonitor->activeWorkspace; - if (workspace_id == -1) return -1; - auto* workspace = g_pCompositor->getWorkspaceByID(workspace_id); - if (workspace == nullptr) return -1; - if (!allow_fullscreen && workspace->m_bHasFullscreenWindow) return -1; + if (!valid(workspace)) return nullptr; + if (!allow_fullscreen && workspace->m_bHasFullscreenWindow) return nullptr; - return workspace_id; + return workspace; } void dispatch_makegroup(std::string value) { - int workspace = workspace_for_action(); - if (workspace == -1) return; + auto workspace = workspace_for_action(); + if (!valid(workspace)) return; auto args = CVarList(value); @@ -44,8 +43,8 @@ void dispatch_makegroup(std::string value) { } void dispatch_changegroup(std::string value) { - int workspace = workspace_for_action(); - if (workspace == -1) return; + auto workspace = workspace_for_action(); + if (!valid(workspace)) return; auto args = CVarList(value); @@ -65,8 +64,8 @@ void dispatch_changegroup(std::string value) { } void dispatch_setephemeral(std::string value) { - int workspace = workspace_for_action(); - if (workspace == -1) return; + auto workspace = workspace_for_action(); + if (!valid(workspace)) return; auto args = CVarList(value); @@ -84,8 +83,8 @@ std::optional parseShiftArg(std::string arg) { } void dispatch_movewindow(std::string value) { - int workspace = workspace_for_action(); - if (workspace == -1) return; + auto workspace = workspace_for_action(); + if (!valid(workspace)) return; auto args = CVarList(value); @@ -109,8 +108,8 @@ void dispatch_movewindow(std::string value) { } void dispatch_movefocus(std::string value) { - int workspace = workspace_for_action(); - if (workspace == -1) return; + auto workspace = workspace_for_action(); + if (!valid(workspace)) return; auto args = CVarList(value); @@ -120,8 +119,8 @@ void dispatch_movefocus(std::string value) { } void dispatch_move_to_workspace(std::string value) { - int origin_workspace = workspace_for_action(true); - if (origin_workspace == -1) return; + auto origin_workspace = workspace_for_action(true); + if (!valid(origin_workspace)) return; auto args = CVarList(value); @@ -134,8 +133,8 @@ void dispatch_move_to_workspace(std::string value) { } void dispatch_changefocus(std::string arg) { - int workspace = workspace_for_action(); - if (workspace == -1) return; + auto workspace = workspace_for_action(); + if (!valid(workspace)) return; if (arg == "top") g_Hy3Layout->changeFocus(workspace, FocusShift::Top); else if (arg == "bottom") g_Hy3Layout->changeFocus(workspace, FocusShift::Bottom); @@ -146,8 +145,8 @@ void dispatch_changefocus(std::string arg) { } void dispatch_focustab(std::string value) { - int workspace = workspace_for_action(); - if (workspace == -1) return; + auto workspace = workspace_for_action(); + if (!valid(workspace)) return; auto i = 0; auto args = CVarList(value); @@ -186,8 +185,8 @@ void dispatch_focustab(std::string value) { } void dispatch_setswallow(std::string arg) { - int workspace = workspace_for_action(); - if (workspace == -1) return; + auto workspace = workspace_for_action(); + if (!valid(workspace)) return; SetSwallowOption option; if (arg == "true") { @@ -202,15 +201,15 @@ void dispatch_setswallow(std::string arg) { } void dispatch_killactive(std::string value) { - int workspace = workspace_for_action(true); - if (workspace == -1) return; + auto workspace = workspace_for_action(true); + if (!valid(workspace)) return; g_Hy3Layout->killFocusedNode(workspace); } void dispatch_expand(std::string value) { - int workspace = workspace_for_action(); - if (workspace == -1) return; + auto workspace = workspace_for_action(); + if (!valid(workspace)) return; auto args = CVarList(value); @@ -234,11 +233,10 @@ void dispatch_expand(std::string value) { } void dispatch_debug(std::string arg) { - int workspace = workspace_for_action(); - if (workspace == -1) return; + auto workspace = workspace_for_action(); auto* root = g_Hy3Layout->getWorkspaceRootGroup(workspace); - if (workspace == -1) { + if (!valid(workspace)) { hy3_log(LOG, "DEBUG NODES: no nodes on workspace"); } else { hy3_log(LOG, "DEBUG NODES\n{}", root->debugNode().c_str()); diff --git a/src/globals.hpp b/src/globals.hpp index 48839ca..ede0c8f 100644 --- a/src/globals.hpp +++ b/src/globals.hpp @@ -2,6 +2,7 @@ #include +#include #include #include From b22f13640f72e5740b31c78a7236b360cfe8c19f Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 3 Apr 2024 21:46:45 -0700 Subject: [PATCH 07/45] misc: reformat --- src/Hy3Layout.cpp | 39 +++++++++++++++++++++++++-------------- src/Hy3Layout.hpp | 8 +++++++- src/TabGroup.cpp | 4 ++-- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index a1f54a0..5c0a02c 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -499,8 +499,7 @@ void Hy3Layout::fullscreenRequestForWindow( bool on ) { if (!g_pCompositor->windowValidMapped(window)) return; - if (on == window->m_bIsFullscreen || window->m_pWorkspace->m_bIsSpecialWorkspace) - return; + if (on == window->m_bIsFullscreen || window->m_pWorkspace->m_bIsSpecialWorkspace) return; const auto monitor = g_pCompositor->getMonitorFromID(window->m_iMonitorID); if (window->m_pWorkspace->m_bHasFullscreenWindow && on) return; @@ -710,7 +709,10 @@ void Hy3Layout::makeGroupOnWorkspace( this->makeGroupOn(node, layout, ephemeral); } -void Hy3Layout::makeOppositeGroupOnWorkspace(const PHLWORKSPACE& workspace, GroupEphemeralityOption ephemeral) { +void Hy3Layout::makeOppositeGroupOnWorkspace( + const PHLWORKSPACE& workspace, + GroupEphemeralityOption ephemeral +) { auto* node = this->getWorkspaceFocusedNode(workspace); this->makeOppositeGroupOn(node, ephemeral); } @@ -864,7 +866,12 @@ void Hy3Layout::shiftNode(Hy3Node& node, ShiftDirection direction, bool once, bo } } -void Hy3Layout::shiftWindow(const PHLWORKSPACE& workspace, ShiftDirection direction, bool once, bool visible) { +void Hy3Layout::shiftWindow( + const PHLWORKSPACE& workspace, + ShiftDirection direction, + bool once, + bool visible +) { auto* node = this->getWorkspaceFocusedNode(workspace); if (node == nullptr) return; @@ -936,8 +943,8 @@ void Hy3Layout::moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsna auto* focused_window_node = this->getNodeFromWindow(focused_window); auto origin_ws = node != nullptr ? node->workspace - : focused_window != nullptr ? focused_window->m_pWorkspace - : nullptr; + : focused_window != nullptr ? focused_window->m_pWorkspace + : nullptr; if (!valid(origin_ws)) return; @@ -1230,7 +1237,11 @@ void Hy3Layout::killFocusedNode(const PHLWORKSPACE& workspace) { } } -void Hy3Layout::expand(const PHLWORKSPACE& workspace, ExpandOption option, ExpandFullscreenOption fs_option) { +void Hy3Layout::expand( + const PHLWORKSPACE& workspace, + ExpandOption option, + ExpandFullscreenOption fs_option +) { auto* node = this->getWorkspaceFocusedNode(workspace, false, true); if (node == nullptr) return; @@ -1498,15 +1509,14 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { if (!window->m_pWorkspace->m_bIsSpecialWorkspace && ((*no_gaps_when_only != 0 && (only_node || window->m_bIsFullscreen)) - || (window->m_bIsFullscreen - && window->m_pWorkspace->m_efFullscreenMode - == FULLSCREEN_FULL))) + || (window->m_bIsFullscreen && window->m_pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL + ))) { window->m_sSpecialRenderData.border = *no_gaps_when_only == 2; - for (auto& workspace_rule : workspace_rules) { + for (auto& workspace_rule: workspace_rules) { if (workspace_rule.border.has_value()) { - //Hyprland src/desktop/Window.cpp, line 1107, SHA 5e8c25d498ed5cb7852ae74a876b0c138a62d59d - //does not break the loop, the last value gets to decide + // Hyprland src/desktop/Window.cpp, line 1107, SHA 5e8c25d498ed5cb7852ae74a876b0c138a62d59d + // does not break the loop, the last value gets to decide window->m_sSpecialRenderData.border = workspace_rule.border.value(); } } @@ -1841,6 +1851,7 @@ bool Hy3Layout::shouldAutotileWorkspace(const PHLWORKSPACE& workspace) { if (this->autotile.workspace_blacklist) { return !this->autotile.workspaces.contains(workspace->m_iID); } else { - return this->autotile.workspaces.empty() || this->autotile.workspaces.contains(workspace->m_iID); + return this->autotile.workspaces.empty() + || this->autotile.workspaces.contains(workspace->m_iID); } } diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index 93333c3..930d91d 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -115,7 +115,13 @@ public: void shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection, bool visible); void moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsname, bool follow); void changeFocus(const PHLWORKSPACE& workspace, FocusShift); - void focusTab(const PHLWORKSPACE& workspace, TabFocus target, TabFocusMousePriority, bool wrap_scroll, int index); + void focusTab( + const PHLWORKSPACE& workspace, + TabFocus target, + TabFocusMousePriority, + bool wrap_scroll, + int index + ); void setNodeSwallow(const PHLWORKSPACE& workspace, SetSwallowOption); void killFocusedNode(const PHLWORKSPACE& workspace); void expand(const PHLWORKSPACE& workspace, ExpandOption, ExpandFullscreenOption); diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 08fe876..d8005b4 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -560,8 +560,8 @@ void Hy3TabGroup::renderTabBar() { glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); } - auto fade_opacity = - this->bar.fade_opacity.value() * (valid(this->workspace) ? this->workspace->m_fAlpha.value() : 1.0); + auto fade_opacity = this->bar.fade_opacity.value() + * (valid(this->workspace) ? this->workspace->m_fAlpha.value() : 1.0); auto render_entry = [&](Hy3TabBarEntry& entry) { Vector2D entry_pos = { From 0177c6fc45ba730c4a6c194ee8ee261ee6d96da4 Mon Sep 17 00:00:00 2001 From: The Darsh <129121284+its-darsh@users.noreply.github.com> Date: Mon, 8 Apr 2024 02:16:00 +0200 Subject: [PATCH 08/45] quick patch for hl38.1 --- src/Hy3Layout.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 5c0a02c..d54b90d 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -1476,7 +1476,7 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { return; } - const auto workspace_rules = g_pConfigManager->getWorkspaceRulesFor(node->workspace); + const auto workspace_rule = g_pConfigManager->getWorkspaceRuleFor(node->workspace); // clang-format off static const auto gaps_in = ConfigValue("general:gaps_in"); @@ -1512,14 +1512,8 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { || (window->m_bIsFullscreen && window->m_pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL ))) { - window->m_sSpecialRenderData.border = *no_gaps_when_only == 2; - for (auto& workspace_rule: workspace_rules) { - if (workspace_rule.border.has_value()) { - // Hyprland src/desktop/Window.cpp, line 1107, SHA 5e8c25d498ed5cb7852ae74a876b0c138a62d59d - // does not break the loop, the last value gets to decide - window->m_sSpecialRenderData.border = workspace_rule.border.value(); - } - } + window->m_sSpecialRenderData.border = workspace_rule.border.value_or(*no_gaps_when_only == 2); + window->m_sSpecialRenderData.rounding = false; window->m_sSpecialRenderData.shadow = false; From 7d988d310f2b15eea5f2b9998f777a9590c4d1d9 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Tue, 9 Apr 2024 02:42:30 -0700 Subject: [PATCH 09/45] version: add 0.38.1 to fix hyprpm --- hyprpm.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hyprpm.toml b/hyprpm.toml index 6149783..6fd226d 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -6,7 +6,8 @@ commit_pins = [ ["84ab8d11e8951a6551d1e1bf87796a8589da6d47", "d3e20856a9896f28b506195b31407eddc6df2e20"], ["1c460e98f870676b15871fe4e5bfeb1a32a3d6d8", "c880e0f00946273ee0304bba9c1de276062d496f"], ["c5e28ebcfe00a510922779b2c568cfa52a317445", "8ac36f3954619a9a5c1a1bb3296f782452987e82"], - ["3875679755014997776e091ff8903acfb311dd2f", "6f9719291386d5e3baad211420d60e54e9967ee6"] + ["3875679755014997776e091ff8903acfb311dd2f", "6f9719291386d5e3baad211420d60e54e9967ee6"], + ["360ede79d124ffdeebbe8401f1ac4bc0dbec2c91", "6f9719291386d5e3baad211420d60e54e9967ee6"] ] [hy3] From 3331340702ecf69229eea3f9268cc05e82c0298e Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 21 Apr 2024 01:08:22 -0700 Subject: [PATCH 10/45] version: update to hyprland 0.39.1 --- flake.lock | 94 +++++++++++++++++------------------------------------ flake.nix | 2 +- hyprpm.toml | 3 +- 3 files changed, 32 insertions(+), 67 deletions(-) diff --git a/flake.lock b/flake.lock index ce30305..df88212 100644 --- a/flake.lock +++ b/flake.lock @@ -2,7 +2,10 @@ "nodes": { "hyprcursor": { "inputs": { - "hyprlang": "hyprlang", + "hyprlang": [ + "hyprland", + "hyprlang" + ], "nixpkgs": [ "hyprland", "nixpkgs" @@ -13,11 +16,11 @@ ] }, "locked": { - "lastModified": 1711466786, - "narHash": "sha256-sArxGyUBiCA1in+q6t0QqT+ZJiZ1PyBp7cNPKLmREM0=", + "lastModified": 1712434681, + "narHash": "sha256-qwmR2p1oc48Bj7gUDvb1oGL19Rjs2PmEmk4ChV01A5o=", "owner": "hyprwm", "repo": "hyprcursor", - "rev": "d3876f34779cc03ee51e4aafc0d00a4f187c7544", + "rev": "818d8c4b69e0997483d60b75f701fe14b561a7a3", "type": "github" }, "original": { @@ -30,22 +33,23 @@ "inputs": { "hyprcursor": "hyprcursor", "hyprland-protocols": "hyprland-protocols", - "hyprlang": "hyprlang_2", + "hyprlang": "hyprlang", "nixpkgs": "nixpkgs", - "systems": "systems_2", + "systems": "systems", "wlroots": "wlroots", "xdph": "xdph" }, "locked": { - "lastModified": 1712189807, - "narHash": "sha256-hmEBPDk1GbpPzpa0gLhJ0XJ5rvt+dMddKNQGr9J8XyA=", + "lastModified": 1713283263, + "narHash": "sha256-Urb/njWiHYUudXpmK8EKl9Z58esTIG0PxXw5LuM2r5g=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "b7d71bc0e1084bc1a296ae906503709a74fde4d9", + "rev": "fe7b748eb668136dd0558b7c8279bfcd7ab4d759", "type": "github" }, "original": { "owner": "hyprwm", + "ref": "fe7b748eb668136dd0558b7c8279bfcd7ab4d759", "repo": "Hyprland", "type": "github" } @@ -76,29 +80,6 @@ } }, "hyprlang": { - "inputs": { - "nixpkgs": [ - "hyprland", - "hyprcursor", - "nixpkgs" - ], - "systems": "systems" - }, - "locked": { - "lastModified": 1709914708, - "narHash": "sha256-bR4o3mynoTa1Wi4ZTjbnsZ6iqVcPGriXp56bZh5UFTk=", - "owner": "hyprwm", - "repo": "hyprlang", - "rev": "a685493fdbeec01ca8ccdf1f3655c044a8ce2fe2", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprlang", - "type": "github" - } - }, - "hyprlang_2": { "inputs": { "nixpkgs": [ "hyprland", @@ -110,11 +91,11 @@ ] }, "locked": { - "lastModified": 1711250455, - "narHash": "sha256-LSq1ZsTpeD7xsqvlsepDEelWRDtAhqwetp6PusHXJRo=", + "lastModified": 1711671891, + "narHash": "sha256-C/Wwsy/RLxHP1axFFl+AnwJRWfd8gxDKKoa8nt8Qk3c=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "b3e430f81f3364c5dd1a3cc9995706a4799eb3fa", + "rev": "c1402612146ba06606ebf64963a02bc1efe11e74", "type": "github" }, "original": { @@ -125,11 +106,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1711523803, - "narHash": "sha256-UKcYiHWHQynzj6CN/vTcix4yd1eCu1uFdsuarupdCQQ=", + "lastModified": 1712439257, + "narHash": "sha256-aSpiNepFOMk9932HOax0XwNxbA38GOUVOiXfUVPOrck=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2726f127c15a4cc9810843b96cad73c7eb39e443", + "rev": "ff0dbd94265ac470dda06a657d5fe49de93b4599", "type": "github" }, "original": { @@ -159,38 +140,21 @@ "type": "github" } }, - "systems_2": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } - }, "wlroots": { "flake": false, "locked": { - "host": "gitlab.freedesktop.org", - "lastModified": 1709983277, - "narHash": "sha256-wXWIJLd4F2JZeMaihWVDW/yYXCLEC8OpeNJZg9a9ly8=", - "owner": "wlroots", - "repo": "wlroots", - "rev": "50eae512d9cecbf0b3b1898bb1f0b40fa05fe19b", - "type": "gitlab" + "lastModified": 1713124002, + "narHash": "sha256-vPeZCY+sdiGsz4fl3AVVujfyZyQBz6+vZdkUE4hQ+HI=", + "owner": "hyprwm", + "repo": "wlroots-hyprland", + "rev": "611a4f24cd2384378f6e500253983107c6656c64", + "type": "github" }, "original": { - "host": "gitlab.freedesktop.org", - "owner": "wlroots", - "repo": "wlroots", - "rev": "50eae512d9cecbf0b3b1898bb1f0b40fa05fe19b", - "type": "gitlab" + "owner": "hyprwm", + "repo": "wlroots-hyprland", + "rev": "611a4f24cd2384378f6e500253983107c6656c64", + "type": "github" } }, "xdph": { diff --git a/flake.nix b/flake.nix index a375308..b6c1b26 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "github:hyprwm/Hyprland"; + hyprland.url = "github:hyprwm/Hyprland?ref=fe7b748eb668136dd0558b7c8279bfcd7ab4d759"; }; outputs = { self, hyprland, ... }: let diff --git a/hyprpm.toml b/hyprpm.toml index 6fd226d..5257db2 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -7,7 +7,8 @@ commit_pins = [ ["1c460e98f870676b15871fe4e5bfeb1a32a3d6d8", "c880e0f00946273ee0304bba9c1de276062d496f"], ["c5e28ebcfe00a510922779b2c568cfa52a317445", "8ac36f3954619a9a5c1a1bb3296f782452987e82"], ["3875679755014997776e091ff8903acfb311dd2f", "6f9719291386d5e3baad211420d60e54e9967ee6"], - ["360ede79d124ffdeebbe8401f1ac4bc0dbec2c91", "6f9719291386d5e3baad211420d60e54e9967ee6"] + ["360ede79d124ffdeebbe8401f1ac4bc0dbec2c91", "6f9719291386d5e3baad211420d60e54e9967ee6"], + ["fe7b748eb668136dd0558b7c8279bfcd7ab4d759", "6f9719291386d5e3baad211420d60e54e9967ee6"] ] [hy3] From e6cabcfa3d303c47406e458f662564d50883b4f2 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 22 Apr 2024 22:30:37 -0700 Subject: [PATCH 11/45] fixup: fix hook + layout breakage fixes #102 --- flake.lock | 66 +++++++++++++++++++++++++++++++++-------------- flake.nix | 2 +- src/Hy3Layout.cpp | 31 ++++++++++------------ src/Hy3Layout.hpp | 2 +- 4 files changed, 62 insertions(+), 39 deletions(-) diff --git a/flake.lock b/flake.lock index df88212..7b5053a 100644 --- a/flake.lock +++ b/flake.lock @@ -16,11 +16,11 @@ ] }, "locked": { - "lastModified": 1712434681, - "narHash": "sha256-qwmR2p1oc48Bj7gUDvb1oGL19Rjs2PmEmk4ChV01A5o=", + "lastModified": 1713612213, + "narHash": "sha256-zJboXgWNpNhKyNF8H/3UYzWkx7w00TOCGKi3cwi+tsw=", "owner": "hyprwm", "repo": "hyprcursor", - "rev": "818d8c4b69e0997483d60b75f701fe14b561a7a3", + "rev": "cab4746180f210a3c1dd3d53e45c510e309e90e1", "type": "github" }, "original": { @@ -34,22 +34,23 @@ "hyprcursor": "hyprcursor", "hyprland-protocols": "hyprland-protocols", "hyprlang": "hyprlang", + "hyprwayland-scanner": "hyprwayland-scanner", "nixpkgs": "nixpkgs", "systems": "systems", "wlroots": "wlroots", "xdph": "xdph" }, "locked": { - "lastModified": 1713283263, - "narHash": "sha256-Urb/njWiHYUudXpmK8EKl9Z58esTIG0PxXw5LuM2r5g=", + "lastModified": 1713819507, + "narHash": "sha256-mG0kD8HmkCsHRkTBmqGb/QvM1vAvkAmB5p2H5XQ0zLo=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "fe7b748eb668136dd0558b7c8279bfcd7ab4d759", + "rev": "da839f20f1b1a57ec78d6b041f8d1369150d253e", "type": "github" }, "original": { "owner": "hyprwm", - "ref": "fe7b748eb668136dd0558b7c8279bfcd7ab4d759", + "ref": "da839f20f1b1a57ec78d6b041f8d1369150d253e", "repo": "Hyprland", "type": "github" } @@ -91,11 +92,11 @@ ] }, "locked": { - "lastModified": 1711671891, - "narHash": "sha256-C/Wwsy/RLxHP1axFFl+AnwJRWfd8gxDKKoa8nt8Qk3c=", + "lastModified": 1713121246, + "narHash": "sha256-502X0Q0fhN6tJK7iEUA8CghONKSatW/Mqj4Wappd++0=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "c1402612146ba06606ebf64963a02bc1efe11e74", + "rev": "78fcaa27ae9e1d782faa3ff06c8ea55ddce63706", "type": "github" }, "original": { @@ -104,13 +105,38 @@ "type": "github" } }, + "hyprwayland-scanner": { + "inputs": { + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1713730424, + "narHash": "sha256-MqYjTvQCxwuDIuAaqIEuyqserm5PYr0auiHHPuYFN/k=", + "owner": "hyprwm", + "repo": "hyprwayland-scanner", + "rev": "7c9c8adfe7e424faa0c5ce6e8be90157fda53c06", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprwayland-scanner", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1712439257, - "narHash": "sha256-aSpiNepFOMk9932HOax0XwNxbA38GOUVOiXfUVPOrck=", + "lastModified": 1713537308, + "narHash": "sha256-XtTSSIB2DA6tOv+l0FhvfDMiyCmhoRbNB+0SeInZkbk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ff0dbd94265ac470dda06a657d5fe49de93b4599", + "rev": "5c24cf2f0a12ad855f444c30b2421d044120c66f", "type": "github" }, "original": { @@ -143,17 +169,17 @@ "wlroots": { "flake": false, "locked": { - "lastModified": 1713124002, - "narHash": "sha256-vPeZCY+sdiGsz4fl3AVVujfyZyQBz6+vZdkUE4hQ+HI=", + "lastModified": 1713731601, + "narHash": "sha256-bdcKdtLkusvv85DNuJsajZLFeq7bXp+x5AGP1Sd4wD8=", "owner": "hyprwm", "repo": "wlroots-hyprland", - "rev": "611a4f24cd2384378f6e500253983107c6656c64", + "rev": "5c1d51c5a2793480f5b6c4341ad0797052aec2ea", "type": "github" }, "original": { "owner": "hyprwm", "repo": "wlroots-hyprland", - "rev": "611a4f24cd2384378f6e500253983107c6656c64", + "rev": "5c1d51c5a2793480f5b6c4341ad0797052aec2ea", "type": "github" } }, @@ -177,11 +203,11 @@ ] }, "locked": { - "lastModified": 1709299639, - "narHash": "sha256-jYqJM5khksLIbqSxCLUUcqEgI+O2LdlSlcMEBs39CAU=", + "lastModified": 1713724432, + "narHash": "sha256-dtU1y4oj/0Y42oauzm93ucFg1AoqETnQ21bmXTIUng0=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "2d2fb547178ec025da643db57d40a971507b82fe", + "rev": "9ace6f969ce495185df34cc6254fb9d297765478", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index b6c1b26..998ea51 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "github:hyprwm/Hyprland?ref=fe7b748eb668136dd0558b7c8279bfcd7ab4d759"; + hyprland.url = "github:hyprwm/Hyprland?ref=da839f20f1b1a57ec78d6b041f8d1369150d253e"; }; outputs = { self, hyprland, ... }: let diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index d54b90d..ca60aa0 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -10,14 +10,10 @@ #include "SelectionHook.hpp" #include "globals.hpp" -std::unique_ptr renderHookPtr = - std::make_unique(Hy3Layout::renderHook); -std::unique_ptr windowTitleHookPtr = - std::make_unique(Hy3Layout::windowGroupUpdateRecursiveHook); -std::unique_ptr urgentHookPtr = - std::make_unique(Hy3Layout::windowGroupUrgentHook); -std::unique_ptr tickHookPtr = - std::make_unique(Hy3Layout::tickHook); +std::shared_ptr renderHookPtr; +std::shared_ptr windowTitleHookPtr; +std::shared_ptr urgentHookPtr; +std::shared_ptr tickHookPtr; bool performContainment(Hy3Node& node, bool contained, CWindow* window) { if (node.data.type == Hy3NodeType::Group) { @@ -604,7 +600,8 @@ void Hy3Layout::switchWindows(CWindow* pWindowA, CWindow* pWindowB) { // todo } -void Hy3Layout::moveWindowTo(CWindow* window, const std::string& direction) { +void Hy3Layout::moveWindowTo(CWindow* window, const std::string& direction, bool silent) { + // todo: support silent auto* node = this->getNodeFromWindow(window); if (node == nullptr) return; @@ -677,18 +674,18 @@ void Hy3Layout::onEnable() { this->onWindowCreatedTiling(window.get()); } - HyprlandAPI::registerCallbackStatic(PHANDLE, "render", renderHookPtr.get()); - HyprlandAPI::registerCallbackStatic(PHANDLE, "windowTitle", windowTitleHookPtr.get()); - HyprlandAPI::registerCallbackStatic(PHANDLE, "urgent", urgentHookPtr.get()); - HyprlandAPI::registerCallbackStatic(PHANDLE, "tick", tickHookPtr.get()); + renderHookPtr = HyprlandAPI::registerCallbackDynamic(PHANDLE, "render", &Hy3Layout::renderHook); + windowTitleHookPtr = HyprlandAPI::registerCallbackDynamic(PHANDLE, "windowTitle", &Hy3Layout::windowGroupUpdateRecursiveHook); + urgentHookPtr = HyprlandAPI::registerCallbackDynamic(PHANDLE, "urgent", &Hy3Layout::windowGroupUrgentHook); + tickHookPtr = HyprlandAPI::registerCallbackDynamic(PHANDLE, "tick", &Hy3Layout::tickHook); selection_hook::enable(); } void Hy3Layout::onDisable() { - HyprlandAPI::unregisterCallback(PHANDLE, renderHookPtr.get()); - HyprlandAPI::unregisterCallback(PHANDLE, windowTitleHookPtr.get()); - HyprlandAPI::unregisterCallback(PHANDLE, urgentHookPtr.get()); - HyprlandAPI::unregisterCallback(PHANDLE, tickHookPtr.get()); + renderHookPtr.reset(); + windowTitleHookPtr.reset(); + urgentHookPtr.reset(); + tickHookPtr.reset(); selection_hook::disable(); for (auto& node: this->nodes) { diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index 930d91d..3bb27de 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -83,7 +83,7 @@ public: virtual std::any layoutMessage(SLayoutMessageHeader header, std::string content); virtual SWindowRenderLayoutHints requestRenderHints(CWindow*); virtual void switchWindows(CWindow*, CWindow*); - virtual void moveWindowTo(CWindow*, const std::string& direction); + virtual void moveWindowTo(CWindow*, const std::string& direction, bool silent); virtual void alterSplitRatio(CWindow*, float, bool); virtual std::string getLayoutName(); virtual CWindow* getNextWindowCandidate(CWindow*); From dc5a0224ce627436aba2e525d46767b1130f0868 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 29 Apr 2024 16:45:23 -0700 Subject: [PATCH 12/45] fixup: fix breakage after hyprland#5762 + improve Hy3NodeData repr Hy3NodeData now uses std::variant instead of a union, and all accesses are checked. --- flake.lock | 19 ++- flake.nix | 2 +- src/Hy3Layout.cpp | 330 +++++++++++++++++++------------------- src/Hy3Layout.hpp | 50 +++--- src/Hy3Node.cpp | 362 ++++++++++++++++++++++-------------------- src/Hy3Node.hpp | 38 ++--- src/SelectionHook.cpp | 6 +- src/TabGroup.cpp | 23 +-- src/TabGroup.hpp | 4 +- 9 files changed, 431 insertions(+), 403 deletions(-) diff --git a/flake.lock b/flake.lock index 7b5053a..50d25e8 100644 --- a/flake.lock +++ b/flake.lock @@ -41,16 +41,15 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1713819507, - "narHash": "sha256-mG0kD8HmkCsHRkTBmqGb/QvM1vAvkAmB5p2H5XQ0zLo=", + "lastModified": 1714409407, + "narHash": "sha256-gc10Ag5O/s+EE24JZUXTpH4ogRsSyAfdgr7OvSNhQ8s=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "da839f20f1b1a57ec78d6b041f8d1369150d253e", + "rev": "f2b03e9679bc1a091fecffd98b50a4179b5c7d43", "type": "github" }, "original": { "owner": "hyprwm", - "ref": "da839f20f1b1a57ec78d6b041f8d1369150d253e", "repo": "Hyprland", "type": "github" } @@ -117,11 +116,11 @@ ] }, "locked": { - "lastModified": 1713730424, - "narHash": "sha256-MqYjTvQCxwuDIuAaqIEuyqserm5PYr0auiHHPuYFN/k=", + "lastModified": 1714171579, + "narHash": "sha256-eaWDIvt8ufUKKz3Lc2a3PyemLJG1m9RYlF+HP3hWbaw=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "7c9c8adfe7e424faa0c5ce6e8be90157fda53c06", + "rev": "126dad854f22fe30e6b82cd21808e76903d90ac5", "type": "github" }, "original": { @@ -132,11 +131,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1713537308, - "narHash": "sha256-XtTSSIB2DA6tOv+l0FhvfDMiyCmhoRbNB+0SeInZkbk=", + "lastModified": 1713714899, + "narHash": "sha256-+z/XjO3QJs5rLE5UOf015gdVauVRQd2vZtsFkaXBq2Y=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5c24cf2f0a12ad855f444c30b2421d044120c66f", + "rev": "6143fc5eeb9c4f00163267708e26191d1e918932", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 998ea51..a375308 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "github:hyprwm/Hyprland?ref=da839f20f1b1a57ec78d6b041f8d1369150d253e"; + hyprland.url = "github:hyprwm/Hyprland"; }; outputs = { self, hyprland, ... }: let diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index ca60aa0..4bfcca8 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -15,18 +16,18 @@ std::shared_ptr windowTitleHookPtr; std::shared_ptr urgentHookPtr; std::shared_ptr tickHookPtr; -bool performContainment(Hy3Node& node, bool contained, CWindow* window) { - if (node.data.type == Hy3NodeType::Group) { - auto& group = node.data.as_group; +bool performContainment(Hy3Node& node, bool contained, PHLWINDOW& window) { + if (node.data.is_group()) { + auto& group = node.data.as_group(); contained |= group.containment; - auto iter = node.data.as_group.children.begin(); - while (iter != node.data.as_group.children.end()) { - switch ((*iter)->data.type) { + auto iter = group.children.begin(); + while (iter != group.children.end()) { + switch ((*iter)->data.type()) { case Hy3NodeType::Group: return performContainment(**iter, contained, window); case Hy3NodeType::Window: if (contained) { - auto wpid = (*iter)->data.as_window->getPID(); + auto wpid = (*iter)->data.as_window()->getPID(); auto ppid = getPPIDof(window->getPID()); while (ppid > 10) { // `> 10` yoinked from HL swallow if (ppid == wpid) { @@ -58,7 +59,7 @@ bool performContainment(Hy3Node& node, bool contained, CWindow* window) { return false; } -void Hy3Layout::onWindowCreated(CWindow* window, eDirection direction) { +void Hy3Layout::onWindowCreated(PHLWINDOW window, eDirection direction) { for (auto& node: this->nodes) { if (node.parent == nullptr && performContainment(node, false, window)) { return; @@ -68,11 +69,11 @@ void Hy3Layout::onWindowCreated(CWindow* window, eDirection direction) { IHyprLayout::onWindowCreated(window, direction); } -void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) { +void Hy3Layout::onWindowCreatedTiling(PHLWINDOW window, eDirection) { hy3_log( LOG, "onWindowCreatedTiling called with window {:x} (floating: {}, monitor: {}, workspace: {})", - (uintptr_t) window, + (uintptr_t) window.get(), window->m_bIsFloating, window->m_iMonitorID, window->m_pWorkspace->m_iID @@ -85,7 +86,7 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) { hy3_log( ERR, "onWindowCreatedTiling called with a window ({:x}) that is already tiled (node: {:x})", - (uintptr_t) window, + (uintptr_t) window.get(), (uintptr_t) existing ); return; @@ -142,16 +143,15 @@ void Hy3Layout::insertNode(Hy3Node& node) { } if (opening_after == nullptr) { - if (g_pCompositor->m_pLastWindow != nullptr - && g_pCompositor->m_pLastWindow->m_pWorkspace == node.workspace - && !g_pCompositor->m_pLastWindow->m_bIsFloating - && (node.data.type == Hy3NodeType::Window - || g_pCompositor->m_pLastWindow != node.data.as_window) - && g_pCompositor->m_pLastWindow->m_bIsMapped) + auto last_window = g_pCompositor->m_pLastWindow.lock(); + if (last_window != nullptr && last_window->m_pWorkspace == node.workspace + && !last_window->m_bIsFloating + && (node.data.is_window() || last_window != node.data.as_window()) + && last_window->m_bIsMapped) { - opening_after = this->getNodeFromWindow(g_pCompositor->m_pLastWindow); + opening_after = this->getNodeFromWindow(last_window); } else { - auto* mouse_window = g_pCompositor->vectorToWindowUnified( + auto mouse_window = g_pCompositor->vectorToWindowUnified( g_pInputManager->getMouseCoordsInternal(), RESERVED_EXTENTS | INPUT_EXTENTS ); @@ -163,8 +163,8 @@ void Hy3Layout::insertNode(Hy3Node& node) { } if (opening_after != nullptr - && ((node.data.type == Hy3NodeType::Group - && (opening_after == &node || node.data.as_group.hasChild(opening_after))) + && ((node.data.is_group() + && (opening_after == &node || node.data.as_group().hasChild(opening_after))) || opening_after->reparenting)) { opening_after = nullptr; @@ -202,14 +202,14 @@ void Hy3Layout::insertNode(Hy3Node& node) { .layout = this, }); - parent.data.as_group.children.push_back(&this->nodes.back()); + parent.data.as_group().children.push_back(&this->nodes.back()); } opening_into = &this->nodes.back(); } } - if (opening_into->data.type != Hy3NodeType::Group) { + if (opening_into->data.is_window()) { hy3_log(ERR, "opening_into node ({:x}) was not a group node", (uintptr_t) opening_into); errorNotif(); return; @@ -236,7 +236,7 @@ void Hy3Layout::insertNode(Hy3Node& node) { this->updateAutotileWorkspaces(); - auto& target_group = opening_into->data.as_group; + auto& target_group = opening_into->data.as_group(); if (*at_enable && opening_after != nullptr && target_group.children.size() > 1 && target_group.layout != Hy3GroupLayout::Tabbed && this->shouldAutotileWorkspace(opening_into->workspace)) @@ -261,9 +261,9 @@ void Hy3Layout::insertNode(Hy3Node& node) { node.reparenting = false; if (opening_after == nullptr) { - opening_into->data.as_group.children.push_back(&node); + opening_into->data.as_group().children.push_back(&node); } else { - auto& children = opening_into->data.as_group.children; + auto& children = opening_into->data.as_group().children; auto iter = std::find(children.begin(), children.end(), opening_after); auto iter2 = std::next(iter); children.insert(iter2, &node); @@ -281,7 +281,7 @@ void Hy3Layout::insertNode(Hy3Node& node) { opening_into->recalcSizePosRecursive(); } -void Hy3Layout::onWindowRemovedTiling(CWindow* window) { +void Hy3Layout::onWindowRemovedTiling(PHLWINDOW window) { static const auto node_collapse_policy = ConfigValue("plugin:hy3:node_collapse_policy"); @@ -292,7 +292,7 @@ void Hy3Layout::onWindowRemovedTiling(CWindow* window) { hy3_log( LOG, "removing window ({:x} as node {:x}) from node {:x}", - (uintptr_t) window, + (uintptr_t) window.get(), (uintptr_t) node, (uintptr_t) node->parent ); @@ -310,17 +310,16 @@ void Hy3Layout::onWindowRemovedTiling(CWindow* window) { this->nodes.remove(*node); if (expand_actor != nullptr) expand_actor->recalcSizePosRecursive(); - auto& group = parent->data.as_group; - if (parent != nullptr) { + auto& group = parent->data.as_group(); parent->recalcSizePosRecursive(); // returns if a given node is a group that can be collapsed given the current config auto node_is_collapsible = [](Hy3Node* node) { - if (node->data.type != Hy3NodeType::Group) return false; + if (node->data.is_window()) return false; if (*node_collapse_policy == 0) return true; else if (*node_collapse_policy == 1) return false; - return node->parent->data.as_group.layout != Hy3GroupLayout::Tabbed; + return node->parent->data.as_group().layout != Hy3GroupLayout::Tabbed; }; if (group.children.size() == 1 @@ -337,14 +336,14 @@ void Hy3Layout::onWindowRemovedTiling(CWindow* window) { } } -void Hy3Layout::onWindowFocusChange(CWindow* window) { +void Hy3Layout::onWindowFocusChange(PHLWINDOW window) { auto* node = this->getNodeFromWindow(window); if (node == nullptr) return; hy3_log( TRACE, "changing window focus to window {:x} as node {:x}", - (uintptr_t) window, + (uintptr_t) window.get(), (uintptr_t) node ); @@ -353,7 +352,7 @@ void Hy3Layout::onWindowFocusChange(CWindow* window) { node->recalcSizePosRecursive(); } -bool Hy3Layout::isWindowTiled(CWindow* window) { +bool Hy3Layout::isWindowTiled(PHLWINDOW window) { return this->getNodeFromWindow(window) != nullptr; } @@ -386,7 +385,7 @@ void Hy3Layout::recalculateMonitor(const int& monitor_id) { } } -void Hy3Layout::recalculateWindow(CWindow* window) { +void Hy3Layout::recalculateWindow(PHLWINDOW window) { auto* node = this->getNodeFromWindow(window); if (node == nullptr) return; node->recalcSizePosRecursive(); @@ -402,9 +401,9 @@ ShiftDirection reverse(ShiftDirection direction) { } } -void Hy3Layout::resizeActiveWindow(const Vector2D& delta, eRectCorner corner, CWindow* pWindow) { - auto window = pWindow ? pWindow : g_pCompositor->m_pLastWindow; - if (!g_pCompositor->windowValidMapped(window)) return; +void Hy3Layout::resizeActiveWindow(const Vector2D& delta, eRectCorner corner, PHLWINDOW pWindow) { + auto window = pWindow ? pWindow : g_pCompositor->m_pLastWindow.lock(); + if (!valid(window)) return; auto* node = this->getNodeFromWindow(window); @@ -427,9 +426,9 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, eRectCorner corner, CW ); Vector2D resize_delta = delta; - bool node_is_root = (node->data.type == Hy3NodeType::Group && node->parent == nullptr) - || (node->data.type == Hy3NodeType::Window - && (node->parent == nullptr || node->parent->parent == nullptr)); + bool node_is_root = + (node->data.is_group() && node->parent == nullptr) + || (node->data.is_window() && (node->parent == nullptr || node->parent->parent == nullptr)); if (node_is_root) { if (display_left && display_right) resize_delta.x = 0; @@ -490,11 +489,10 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, eRectCorner corner, CW } void Hy3Layout::fullscreenRequestForWindow( - CWindow* window, + PHLWINDOW window, eFullscreenMode fullscreen_mode, bool on ) { - if (!g_pCompositor->windowValidMapped(window)) return; if (on == window->m_bIsFullscreen || window->m_pWorkspace->m_bIsSpecialWorkspace) return; const auto monitor = g_pCompositor->getMonitorFromID(window->m_iMonitorID); @@ -575,7 +573,7 @@ std::any Hy3Layout::layoutMessage(SLayoutMessageHeader header, std::string conte if (content == "togglesplit") { auto* node = this->getNodeFromWindow(header.pWindow); if (node != nullptr && node->parent != nullptr) { - auto& layout = node->parent->data.as_group.layout; + auto& layout = node->parent->data.as_group().layout; switch (layout) { case Hy3GroupLayout::SplitH: @@ -594,13 +592,13 @@ std::any Hy3Layout::layoutMessage(SLayoutMessageHeader header, std::string conte return ""; } -SWindowRenderLayoutHints Hy3Layout::requestRenderHints(CWindow* window) { return {}; } +SWindowRenderLayoutHints Hy3Layout::requestRenderHints(PHLWINDOW window) { return {}; } -void Hy3Layout::switchWindows(CWindow* pWindowA, CWindow* pWindowB) { +void Hy3Layout::switchWindows(PHLWINDOW pWindowA, PHLWINDOW pWindowB) { // todo } -void Hy3Layout::moveWindowTo(CWindow* window, const std::string& direction, bool silent) { +void Hy3Layout::moveWindowTo(PHLWINDOW window, const std::string& direction, bool silent) { // todo: support silent auto* node = this->getNodeFromWindow(window); if (node == nullptr) return; @@ -615,13 +613,13 @@ void Hy3Layout::moveWindowTo(CWindow* window, const std::string& direction, bool this->shiftNode(*node, shift, false, false); } -void Hy3Layout::alterSplitRatio(CWindow* pWindow, float delta, bool exact) { +void Hy3Layout::alterSplitRatio(PHLWINDOW pWindow, float delta, bool exact) { // todo } std::string Hy3Layout::getLayoutName() { return "hy3"; } -CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) { +PHLWINDOW Hy3Layout::getNextWindowCandidate(PHLWINDOW window) { if (window->m_pWorkspace->m_bHasFullscreenWindow) { return g_pCompositor->getFullscreenWindowOnWorkspace(window->m_pWorkspace->m_iID); } @@ -631,9 +629,9 @@ CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) { for (auto& w: g_pCompositor->m_vWindows | std::views::reverse) { if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_pWorkspace == window->m_pWorkspace && !w->m_bX11ShouldntFocus - && !w->m_sAdditionalConfigData.noFocus && w.get() != window) + && !w->m_sAdditionalConfigData.noFocus && w != window) { - return w.get(); + return w; } } } @@ -641,26 +639,26 @@ CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) { auto* node = this->getWorkspaceFocusedNode(window->m_pWorkspace, true); if (node == nullptr) return nullptr; - switch (node->data.type) { - case Hy3NodeType::Window: return node->data.as_window; - case Hy3NodeType::Group: return nullptr; - default: return nullptr; + if (node->data.is_window()) { + return node->data.as_window(); + } else { + return nullptr; } } -void Hy3Layout::replaceWindowDataWith(CWindow* from, CWindow* to) { +void Hy3Layout::replaceWindowDataWith(PHLWINDOW from, PHLWINDOW to) { auto* node = this->getNodeFromWindow(from); if (node == nullptr) return; - node->data.as_window = to; + node->data.as_window() = to; this->applyNodeDataToWindow(node); } -bool Hy3Layout::isWindowReachable(CWindow* window) { +bool Hy3Layout::isWindowReachable(PHLWINDOW window) { return this->getNodeFromWindow(window) != nullptr || IHyprLayout::isWindowReachable(window); } -void Hy3Layout::bringWindowToTop(CWindow* window) { +void Hy3Layout::bringWindowToTop(PHLWINDOW window) { auto node = this->getNodeFromWindow(window); if (node == nullptr) return; node->bringToTop(); @@ -671,12 +669,17 @@ void Hy3Layout::onEnable() { if (window->isHidden() || !window->m_bIsMapped || window->m_bFadingOut || window->m_bIsFloating) continue; - this->onWindowCreatedTiling(window.get()); + this->onWindowCreatedTiling(window); } renderHookPtr = HyprlandAPI::registerCallbackDynamic(PHANDLE, "render", &Hy3Layout::renderHook); - windowTitleHookPtr = HyprlandAPI::registerCallbackDynamic(PHANDLE, "windowTitle", &Hy3Layout::windowGroupUpdateRecursiveHook); - urgentHookPtr = HyprlandAPI::registerCallbackDynamic(PHANDLE, "urgent", &Hy3Layout::windowGroupUrgentHook); + windowTitleHookPtr = HyprlandAPI::registerCallbackDynamic( + PHANDLE, + "windowTitle", + &Hy3Layout::windowGroupUpdateRecursiveHook + ); + urgentHookPtr = + HyprlandAPI::registerCallbackDynamic(PHANDLE, "urgent", &Hy3Layout::windowGroupUrgentHook); tickHookPtr = HyprlandAPI::registerCallbackDynamic(PHANDLE, "tick", &Hy3Layout::tickHook); selection_hook::enable(); } @@ -689,8 +692,8 @@ void Hy3Layout::onDisable() { selection_hook::disable(); for (auto& node: this->nodes) { - if (node.data.type == Hy3NodeType::Window) { - node.data.as_window->setHidden(false); + if (node.data.is_window()) { + node.data.as_window()->setHidden(false); } } @@ -757,7 +760,7 @@ void Hy3Layout::makeGroupOn( if (node == nullptr) return; if (node->parent != nullptr) { - auto& group = node->parent->data.as_group; + auto& group = node->parent->data.as_group(); if (group.children.size() == 1) { group.setLayout(layout); group.setEphemeral(ephemeral); @@ -778,7 +781,7 @@ void Hy3Layout::makeOppositeGroupOn(Hy3Node* node, GroupEphemeralityOption ephem return; } - auto& group = node->parent->data.as_group; + auto& group = node->parent->data.as_group(); auto layout = group.layout == Hy3GroupLayout::SplitH ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH; @@ -798,7 +801,7 @@ void Hy3Layout::changeGroupOn(Hy3Node& node, Hy3GroupLayout layout) { return; } - auto& group = node.parent->data.as_group; + auto& group = node.parent->data.as_group(); group.setLayout(layout); node.parent->updateTabBarRecursive(); node.parent->recalcSizePosRecursive(); @@ -807,7 +810,7 @@ void Hy3Layout::changeGroupOn(Hy3Node& node, Hy3GroupLayout layout) { void Hy3Layout::untabGroupOn(Hy3Node& node) { if (node.parent == nullptr) return; - auto& group = node.parent->data.as_group; + auto& group = node.parent->data.as_group(); if (group.layout != Hy3GroupLayout::Tabbed) return; changeGroupOn(node, group.previous_nontab_layout); @@ -816,7 +819,7 @@ void Hy3Layout::untabGroupOn(Hy3Node& node) { void Hy3Layout::toggleTabGroupOn(Hy3Node& node) { if (node.parent == nullptr) return; - auto& group = node.parent->data.as_group; + auto& group = node.parent->data.as_group(); if (group.layout != Hy3GroupLayout::Tabbed) changeGroupOn(node, Hy3GroupLayout::Tabbed); else changeGroupOn(node, group.previous_nontab_layout); } @@ -824,7 +827,7 @@ void Hy3Layout::toggleTabGroupOn(Hy3Node& node) { void Hy3Layout::changeGroupToOppositeOn(Hy3Node& node) { if (node.parent == nullptr) return; - auto& group = node.parent->data.as_group; + auto& group = node.parent->data.as_group(); if (group.layout == Hy3GroupLayout::Tabbed) { group.setLayout(group.previous_nontab_layout); @@ -840,16 +843,16 @@ void Hy3Layout::changeGroupToOppositeOn(Hy3Node& node) { void Hy3Layout::changeGroupEphemeralityOn(Hy3Node& node, bool ephemeral) { if (node.parent == nullptr) return; - auto& group = node.parent->data.as_group; + auto& group = node.parent->data.as_group(); group.setEphemeral( ephemeral ? GroupEphemeralityOption::ForceEphemeral : GroupEphemeralityOption::Standard ); } void Hy3Layout::shiftNode(Hy3Node& node, ShiftDirection direction, bool once, bool visible) { - if (once && node.parent != nullptr && node.parent->data.as_group.children.size() == 1) { + if (once && node.parent != nullptr && node.parent->data.as_group().children.size() == 1) { if (node.parent->parent == nullptr) { - node.parent->data.as_group.setLayout(Hy3GroupLayout::SplitH); + node.parent->data.as_group().setLayout(Hy3GroupLayout::SplitH); node.parent->recalcSizePosRecursive(); } else { auto* node2 = node.parent; @@ -876,13 +879,13 @@ void Hy3Layout::shiftWindow( } void Hy3Layout::shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection direction, bool visible) { - auto* current_window = g_pCompositor->m_pLastWindow; + auto current_window = g_pCompositor->m_pLastWindow.lock(); if (current_window != nullptr) { if (current_window->m_pWorkspace->m_bHasFullscreenWindow) return; if (current_window->m_bIsFloating) { - auto* next_window = g_pCompositor->getWindowInDirection( + auto next_window = g_pCompositor->getWindowInDirection( current_window, direction == ShiftDirection::Left ? 'l' : direction == ShiftDirection::Up ? 'u' @@ -910,13 +913,13 @@ void Hy3Layout::shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection directi void changeNodeWorkspaceRecursive(Hy3Node& node, const PHLWORKSPACE& workspace) { node.workspace = workspace; - if (node.data.type == Hy3NodeType::Window) { - auto* window = node.data.as_window; + if (node.data.is_window()) { + auto window = node.data.as_window(); window->moveToWorkspace(workspace); window->updateToplevel(); window->updateDynamicRules(); } else { - for (auto* child: node.data.as_group.children) { + for (auto* child: node.data.as_group().children) { changeNodeWorkspaceRecursive(*child, workspace); } } @@ -936,7 +939,7 @@ void Hy3Layout::moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsna if (origin == workspace) return; auto* node = this->getWorkspaceFocusedNode(origin); - auto* focused_window = g_pCompositor->m_pLastWindow; + auto focused_window = g_pCompositor->m_pLastWindow.lock(); auto* focused_window_node = this->getNodeFromWindow(focused_window); auto origin_ws = node != nullptr ? node->workspace @@ -1013,14 +1016,14 @@ void Hy3Layout::changeFocus(const PHLWORKSPACE& workspace, FocusShift shift) { } return; case FocusShift::Lower: - if (node->data.type == Hy3NodeType::Group && node->data.as_group.focused_child != nullptr) - node->data.as_group.focused_child->focus(); + if (node->data.is_group() && node->data.as_group().focused_child != nullptr) + node->data.as_group().focused_child->focus(); return; case FocusShift::Tab: // make sure we go up at least one level if (node->parent != nullptr) node = node->parent; while (node->parent != nullptr) { - if (node->data.as_group.layout == Hy3GroupLayout::Tabbed) { + if (node->data.as_group().layout == Hy3GroupLayout::Tabbed) { node->focus(); return; } @@ -1032,7 +1035,7 @@ void Hy3Layout::changeFocus(const PHLWORKSPACE& workspace, FocusShift shift) { // make sure we go up at least one level if (node->parent != nullptr) node = node->parent; while (node->parent != nullptr) { - if (node->parent->data.as_group.layout == Hy3GroupLayout::Tabbed) { + if (node->parent->data.as_group().layout == Hy3GroupLayout::Tabbed) { node->focus(); return; } @@ -1043,8 +1046,8 @@ void Hy3Layout::changeFocus(const PHLWORKSPACE& workspace, FocusShift shift) { } bottom: - while (node->data.type == Hy3NodeType::Group && node->data.as_group.focused_child != nullptr) { - node = node->data.as_group.focused_child; + while (node->data.is_group() && node->data.as_group().focused_child != nullptr) { + node = node->data.as_group().focused_child; } node->focus(); @@ -1067,19 +1070,19 @@ Hy3Node* findTabBarAt(Hy3Node& node, Vector2D pos, Hy3Node** focused_node) { inset += gaps_in->left; } - if (node.data.type == Hy3NodeType::Group) { + if (node.data.is_group()) { if (node.hidden) return nullptr; // note: tab bar clicks ignore animations if (node.position.x > pos.x || node.position.y > pos.y || node.position.x + node.size.x < pos.x || node.position.y + node.size.y < pos.y) return nullptr; - if (node.data.as_group.layout == Hy3GroupLayout::Tabbed - && node.data.as_group.tab_bar != nullptr) - { + auto& group = node.data.as_group(); + + if (group.layout == Hy3GroupLayout::Tabbed && node.data.as_group().tab_bar != nullptr) { if (pos.y < node.position.y + node.gap_topleft_offset.y + inset) { - auto& children = node.data.as_group.children; - auto& tab_bar = *node.data.as_group.tab_bar; + auto& children = group.children; + auto& tab_bar = *group.tab_bar; auto size = tab_bar.size.value(); auto x = pos.x - tab_bar.pos.value().x; @@ -1099,11 +1102,11 @@ Hy3Node* findTabBarAt(Hy3Node& node, Vector2D pos, Hy3Node** focused_node) { } } - if (node.data.as_group.focused_child != nullptr) { - return findTabBarAt(*node.data.as_group.focused_child, pos, focused_node); + if (group.focused_child != nullptr) { + return findTabBarAt(*group.focused_child, pos, focused_node); } } else { - for (auto child: node.data.as_group.children) { + for (auto child: group.children) { if (findTabBarAt(*child, pos, focused_node)) return child; } } @@ -1144,22 +1147,21 @@ void Hy3Layout::focusTab( tab_node = this->getWorkspaceFocusedNode(workspace); if (tab_node == nullptr) return; - while (tab_node != nullptr && tab_node->data.as_group.layout != Hy3GroupLayout::Tabbed + while (tab_node != nullptr && tab_node->data.as_group().layout != Hy3GroupLayout::Tabbed && tab_node->parent != nullptr) tab_node = tab_node->parent; - if (tab_node == nullptr || tab_node->data.type != Hy3NodeType::Group - || tab_node->data.as_group.layout != Hy3GroupLayout::Tabbed) + if (tab_node == nullptr || tab_node->data.is_window() + || tab_node->data.as_group().layout != Hy3GroupLayout::Tabbed) return; } hastab: if (target != TabFocus::MouseLocation) { - if (tab_node->data.as_group.focused_child == nullptr - || tab_node->data.as_group.children.size() < 2) - return; + auto& group = tab_node->data.as_group(); + if (group.focused_child == nullptr || group.children.size() < 2) return; - auto& children = tab_node->data.as_group.children; + auto& children = group.children; if (target == TabFocus::Index) { int i = 1; @@ -1175,8 +1177,7 @@ hastab: return; cont:; } else { - auto node_iter = - std::find(children.begin(), children.end(), tab_node->data.as_group.focused_child); + auto node_iter = std::find(children.begin(), children.end(), group.focused_child); if (node_iter == children.end()) return; if (target == TabFocus::Left) { if (node_iter == children.begin()) { @@ -1197,9 +1198,9 @@ hastab: } auto* focus = tab_focused_node; - while (focus->data.type == Hy3NodeType::Group && !focus->data.as_group.group_focused - && focus->data.as_group.focused_child != nullptr) - focus = focus->data.as_group.focused_child; + while (focus->data.is_group() && !focus->data.as_group().group_focused + && focus->data.as_group().focused_child != nullptr) + focus = focus->data.as_group().focused_child; focus->focus(); tab_node->recalcSizePosRecursive(); @@ -1209,7 +1210,7 @@ void Hy3Layout::setNodeSwallow(const PHLWORKSPACE& workspace, SetSwallowOption o auto* node = this->getWorkspaceFocusedNode(workspace); if (node == nullptr || node->parent == nullptr) return; - auto* containment = &node->parent->data.as_group.containment; + auto* containment = &node->parent->data.as_group().containment; switch (option) { case SetSwallowOption::NoSwallow: *containment = false; break; case SetSwallowOption::Swallow: *containment = true; break; @@ -1218,16 +1219,17 @@ void Hy3Layout::setNodeSwallow(const PHLWORKSPACE& workspace, SetSwallowOption o } void Hy3Layout::killFocusedNode(const PHLWORKSPACE& workspace) { - if (g_pCompositor->m_pLastWindow != nullptr && g_pCompositor->m_pLastWindow->m_bIsFloating) { - g_pCompositor->closeWindow(g_pCompositor->m_pLastWindow); + auto last_window = g_pCompositor->m_pLastWindow.lock(); + if (last_window != nullptr && last_window->m_bIsFloating) { + g_pCompositor->closeWindow(last_window); } else { auto* node = this->getWorkspaceFocusedNode(workspace); if (node == nullptr) return; - std::vector windows; + std::vector windows; node->appendAllWindows(windows); - for (auto* window: windows) { + for (auto& window: windows) { window->setHidden(false); g_pCompositor->closeWindow(window); } @@ -1241,6 +1243,7 @@ void Hy3Layout::expand( ) { auto* node = this->getWorkspaceFocusedNode(workspace, false, true); if (node == nullptr) return; + PHLWINDOW window; const auto monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID); @@ -1254,10 +1257,10 @@ void Hy3Layout::expand( } } - if (node->data.type == Hy3NodeType::Group && !node->data.as_group.group_focused) - node->data.as_group.expand_focused = ExpandFocusType::Stack; + if (node->data.is_group() && !node->data.as_group().group_focused) + node->data.as_group().expand_focused = ExpandFocusType::Stack; - auto& group = node->parent->data.as_group; + auto& group = node->parent->data.as_group(); group.focused_child = node; group.expand_focused = ExpandFocusType::Latch; @@ -1272,19 +1275,19 @@ void Hy3Layout::expand( } } break; case ExpandOption::Shrink: - if (node->data.type == Hy3NodeType::Group) { - auto& group = node->data.as_group; + if (node->data.is_group()) { + auto& group = node->data.as_group(); group.expand_focused = ExpandFocusType::NotExpanded; - if (group.focused_child->data.type == Hy3NodeType::Group) - group.focused_child->data.as_group.expand_focused = ExpandFocusType::Latch; + if (group.focused_child->data.is_group()) + group.focused_child->data.as_group().expand_focused = ExpandFocusType::Latch; node->recalcSizePosRecursive(); } break; case ExpandOption::Base: { - if (node->data.type == Hy3NodeType::Group) { - node->data.as_group.collapseExpansions(); + if (node->data.is_group()) { + node->data.as_group().collapseExpansions(); node->recalcSizePosRecursive(); } break; @@ -1295,10 +1298,9 @@ void Hy3Layout::expand( return; - CWindow* window; fullscreen: - if (node->data.type != Hy3NodeType::Window) return; - window = node->data.as_window; + if (node->data.is_group()) return; + window = node->data.as_window(); if (!window->m_bIsFullscreen || window->m_pWorkspace->m_bIsSpecialWorkspace) return; if (workspace->m_bHasFullscreenWindow) return; @@ -1322,31 +1324,30 @@ fsupdate: this->recalculateMonitor(monitor->ID); } -bool Hy3Layout::shouldRenderSelected(CWindow* window) { +bool Hy3Layout::shouldRenderSelected(const PHLWINDOW& window) { if (window == nullptr) return false; auto* root = this->getWorkspaceRootGroup(window->m_pWorkspace); - if (root == nullptr || root->data.as_group.focused_child == nullptr) return false; + if (root == nullptr || root->data.as_group().focused_child == nullptr) return false; auto* focused = root->getFocusedNode(); if (focused == nullptr - || (focused->data.type == Hy3NodeType::Window - && focused->data.as_window != g_pCompositor->m_pLastWindow)) + || (focused->data.is_window() + && focused->data.as_window() != g_pCompositor->m_pLastWindow.lock())) return false; - switch (focused->data.type) { - case Hy3NodeType::Window: return focused->data.as_window == window; + switch (focused->data.type()) { + case Hy3NodeType::Window: return focused->data.as_window() == window; case Hy3NodeType::Group: { auto* node = this->getNodeFromWindow(window); if (node == nullptr) return false; - return focused->data.as_group.hasChild(node); + return focused->data.as_group().hasChild(node); } - default: return false; } } Hy3Node* Hy3Layout::getWorkspaceRootGroup(const PHLWORKSPACE& workspace) { for (auto& node: this->nodes) { - if (node.workspace == workspace && node.parent == nullptr - && node.data.type == Hy3NodeType::Group && !node.reparenting) + if (node.workspace == workspace && node.parent == nullptr && node.data.is_group() + && !node.reparenting) { return &node; } @@ -1380,7 +1381,7 @@ void Hy3Layout::renderHook(void*, SCallbackInfo&, std::any data) { if (!rendering_normally) break; for (auto& entry: g_Hy3Layout->tab_groups) { - if (!entry.hidden && entry.target_window == g_pHyprOpenGL->m_pCurrentWindow + if (!entry.hidden && entry.target_window == g_pHyprOpenGL->m_pCurrentWindow.lock() && std::find(rendered_groups.begin(), rendered_groups.end(), &entry) == rendered_groups.end()) { @@ -1409,18 +1410,17 @@ void Hy3Layout::renderHook(void*, SCallbackInfo&, std::any data) { } void Hy3Layout::windowGroupUrgentHook(void* p, SCallbackInfo& callback_info, std::any data) { - CWindow* window = std::any_cast(data); + auto window = std::any_cast(data); if (window == nullptr) return; window->m_bIsUrgent = true; Hy3Layout::windowGroupUpdateRecursiveHook(p, callback_info, data); } void Hy3Layout::windowGroupUpdateRecursiveHook(void*, SCallbackInfo&, std::any data) { - CWindow* window = std::any_cast(data); + auto window = std::any_cast(data); if (window == nullptr) return; auto* node = g_Hy3Layout->getNodeFromWindow(window); - // it is UB for `this` to be null if (node == nullptr) return; node->updateTabBarRecursive(); } @@ -1435,9 +1435,9 @@ void Hy3Layout::tickHook(void*, SCallbackInfo&, std::any) { } } -Hy3Node* Hy3Layout::getNodeFromWindow(CWindow* window) { +Hy3Node* Hy3Layout::getNodeFromWindow(const PHLWINDOW& window) { for (auto& node: this->nodes) { - if (node.data.type == Hy3NodeType::Window && node.data.as_window == window) { + if (node.data.is_window() && node.data.as_window() == window) { return &node; } } @@ -1446,8 +1446,8 @@ Hy3Node* Hy3Layout::getNodeFromWindow(CWindow* window) { } void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { - if (node->data.type != Hy3NodeType::Window) return; - auto* window = node->data.as_window; + if (node->data.is_group()) return; + auto window = node->data.as_window(); auto root_node = this->getWorkspaceRootGroup(window->m_pWorkspace); CMonitor* monitor = nullptr; @@ -1480,13 +1480,13 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { static const auto no_gaps_when_only = ConfigValue("plugin:hy3:no_gaps_when_only"); // clang-format on - if (!g_pCompositor->windowExists(window) || !window->m_bIsMapped) { + if (!valid(window) || !window->m_bIsMapped) { hy3_log( ERR, "node {:x} is an unmapped window ({:x}), cannot apply node data, removing from tiled " "layout", (uintptr_t) node, - (uintptr_t) window + (uintptr_t) window.get() ); errorNotif(); this->onWindowRemovedTiling(window); @@ -1501,8 +1501,8 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { window->m_vSize = nodeBox.size(); window->m_vPosition = nodeBox.pos(); - auto only_node = root_node != nullptr && root_node->data.as_group.children.size() == 1 - && root_node->data.as_group.children.front()->data.type == Hy3NodeType::Window; + auto only_node = root_node != nullptr && root_node->data.as_group().children.size() == 1 + && root_node->data.as_group().children.front()->data.is_window(); if (!window->m_pWorkspace->m_bIsSpecialWorkspace && ((*no_gaps_when_only != 0 && (only_node || window->m_bIsFullscreen)) @@ -1589,7 +1589,7 @@ Hy3Node* Hy3Layout::shiftOrGetFocus( while (true) { if (break_parent == nullptr) return nullptr; - auto& group = break_parent->data.as_group; // must be a group in order to be a parent + auto& group = break_parent->data.as_group(); // must be a group in order to be a parent if (shiftMatchesLayout(group.layout, direction) && (!visible || group.layout != Hy3GroupLayout::Tabbed)) @@ -1636,9 +1636,10 @@ Hy3Node* Hy3Layout::shiftOrGetFocus( auto* newChild = &this->nodes.back(); Hy3Node::swapData(*break_parent, *newChild); - break_parent->data.as_group.children.push_back(newChild); - break_parent->data.as_group.group_focused = false; - break_parent->data.as_group.focused_child = newChild; + auto& group = break_parent->data.as_group(); + group.children.push_back(newChild); + group.group_focused = false; + group.focused_child = newChild; break_origin = newChild; } @@ -1649,7 +1650,7 @@ Hy3Node* Hy3Layout::shiftOrGetFocus( } } - auto& parent_group = break_parent->data.as_group; + auto& parent_group = break_parent->data.as_group(); Hy3Node* target_group = break_parent; std::list::iterator insert; @@ -1660,15 +1661,15 @@ Hy3Node* Hy3Layout::shiftOrGetFocus( if (!shift) return nullptr; insert = parent_group.children.end(); } else { - auto& group_data = target_group->data.as_group; + auto& group_data = target_group->data.as_group(); auto iter = std::find(group_data.children.begin(), group_data.children.end(), break_origin); if (shiftIsForward(direction)) iter = std::next(iter); else iter = std::prev(iter); - if ((*iter)->data.type == Hy3NodeType::Window - || ((*iter)->data.type == Hy3NodeType::Group - && (*iter)->data.as_group.expand_focused != ExpandFocusType::NotExpanded) + if ((*iter)->data.is_window() + || ((*iter)->data.is_group() + && (*iter)->data.as_group().expand_focused != ExpandFocusType::NotExpanded) || (shift && once && has_broken_once)) { if (shift) { @@ -1684,7 +1685,7 @@ Hy3Node* Hy3Layout::shiftOrGetFocus( // break into neighboring groups until we hit a window while (true) { target_group = *iter; - auto& group_data = target_group->data.as_group; + auto& group_data = target_group->data.as_group(); if (group_data.children.empty()) return nullptr; // in theory this would never happen @@ -1735,9 +1736,9 @@ Hy3Node* Hy3Layout::shiftOrGetFocus( break; } - if ((*iter)->data.type == Hy3NodeType::Window - || ((*iter)->data.type == Hy3NodeType::Group - && (*iter)->data.as_group.expand_focused != ExpandFocusType::NotExpanded)) + if ((*iter)->data.is_window() + || ((*iter)->data.is_group() + && (*iter)->data.as_group().expand_focused != ExpandFocusType::NotExpanded)) { if (shift) { if (shift_after) insert = std::next(iter); @@ -1751,18 +1752,19 @@ Hy3Node* Hy3Layout::shiftOrGetFocus( } } - auto& group_data = target_group->data.as_group; + auto& group_data = target_group->data.as_group(); if (target_group == node.parent) { // nullptr is used as a signal value instead of removing it first to avoid // iterator invalidation. auto iter = std::find(group_data.children.begin(), group_data.children.end(), &node); *iter = nullptr; - target_group->data.as_group.children.insert(insert, &node); - target_group->data.as_group.children.remove(nullptr); + auto& group = target_group->data.as_group(); + group.children.insert(insert, &node); + group.children.remove(nullptr); target_group->recalcSizePosRecursive(); } else { - target_group->data.as_group.children.insert(insert, &node); + target_group->data.as_group().children.insert(insert, &node); // must happen AFTER `insert` is used auto* old_parent = node.removeFromParentRecursive(nullptr); @@ -1770,7 +1772,7 @@ Hy3Node* Hy3Layout::shiftOrGetFocus( node.size_ratio = 1.0; if (old_parent != nullptr) { - auto& group = old_parent->data.as_group; + auto& group = old_parent->data.as_group(); if (old_parent->parent != nullptr && group.ephemeral && group.children.size() == 1 && !group.hasChild(&node)) { diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index 3bb27de..7916261 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -70,30 +70,30 @@ enum class ExpandFullscreenOption { class Hy3Layout: public IHyprLayout { public: - virtual void onWindowCreated(CWindow*, eDirection = DIRECTION_DEFAULT); - virtual void onWindowCreatedTiling(CWindow*, eDirection = DIRECTION_DEFAULT); - virtual void onWindowRemovedTiling(CWindow*); - virtual void onWindowFocusChange(CWindow*); - virtual bool isWindowTiled(CWindow*); - virtual void recalculateMonitor(const int& monitor_id); - virtual void recalculateWindow(CWindow*); - virtual void - resizeActiveWindow(const Vector2D& delta, eRectCorner corner, CWindow* pWindow = nullptr); - virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool enable_fullscreen); - virtual std::any layoutMessage(SLayoutMessageHeader header, std::string content); - virtual SWindowRenderLayoutHints requestRenderHints(CWindow*); - virtual void switchWindows(CWindow*, CWindow*); - virtual void moveWindowTo(CWindow*, const std::string& direction, bool silent); - virtual void alterSplitRatio(CWindow*, float, bool); - virtual std::string getLayoutName(); - virtual CWindow* getNextWindowCandidate(CWindow*); - virtual void replaceWindowDataWith(CWindow* from, CWindow* to); - virtual bool isWindowReachable(CWindow*); - virtual void bringWindowToTop(CWindow*); - virtual Vector2D predictSizeForNewWindowTiled() { return Vector2D(); } + void onWindowCreated(PHLWINDOW, eDirection = DIRECTION_DEFAULT) override; + void onWindowCreatedTiling(PHLWINDOW, eDirection = DIRECTION_DEFAULT) override; + void onWindowRemovedTiling(PHLWINDOW) override; + void onWindowFocusChange(PHLWINDOW) override; + bool isWindowTiled(PHLWINDOW) override; + void recalculateMonitor(const int& monitor_id) override; + void recalculateWindow(PHLWINDOW) override; + void resizeActiveWindow(const Vector2D& delta, eRectCorner corner, PHLWINDOW pWindow = nullptr) + override; + void fullscreenRequestForWindow(PHLWINDOW, eFullscreenMode, bool enable_fullscreen) override; + std::any layoutMessage(SLayoutMessageHeader header, std::string content) override; + SWindowRenderLayoutHints requestRenderHints(PHLWINDOW) override; + void switchWindows(PHLWINDOW, PHLWINDOW) override; + void moveWindowTo(PHLWINDOW, const std::string& direction, bool silent) override; + void alterSplitRatio(PHLWINDOW, float, bool) override; + std::string getLayoutName() override; + PHLWINDOW getNextWindowCandidate(PHLWINDOW) override; + void replaceWindowDataWith(PHLWINDOW from, PHLWINDOW to) override; + bool isWindowReachable(PHLWINDOW) override; + void bringWindowToTop(PHLWINDOW) override; + Vector2D predictSizeForNewWindowTiled() override { return Vector2D(); } - virtual void onEnable(); - virtual void onDisable(); + void onEnable() override; + void onDisable() override; void insertNode(Hy3Node& node); void makeGroupOnWorkspace(const PHLWORKSPACE& workspace, Hy3GroupLayout, GroupEphemeralityOption); @@ -126,7 +126,7 @@ public: void killFocusedNode(const PHLWORKSPACE& workspace); void expand(const PHLWORKSPACE& workspace, ExpandOption, ExpandFullscreenOption); - bool shouldRenderSelected(CWindow*); + bool shouldRenderSelected(const PHLWINDOW&); Hy3Node* getWorkspaceRootGroup(const PHLWORKSPACE& workspace); Hy3Node* getWorkspaceFocusedNode( @@ -144,7 +144,7 @@ public: std::list tab_groups; private: - Hy3Node* getNodeFromWindow(CWindow*); + Hy3Node* getNodeFromWindow(const PHLWINDOW&); void applyNodeDataToWindow(Hy3Node*, bool no_animation = false); // if shift is true, shift the window in the given direction, returning diff --git a/src/Hy3Node.cpp b/src/Hy3Node.cpp index 9572d7b..04ef6f5 100644 --- a/src/Hy3Node.cpp +++ b/src/Hy3Node.cpp @@ -1,6 +1,10 @@ #include +#include +#include +#include #include +#include #include #include @@ -37,8 +41,8 @@ bool Hy3GroupData::hasChild(Hy3Node* node) { for (auto child: this->children) { if (child == node) return true; - if (child->data.type == Hy3NodeType::Group) { - if (child->data.as_group.hasChild(node)) return true; + if (child->data.is_group()) { + if (child->data.as_group().hasChild(node)) return true; } } @@ -51,11 +55,10 @@ void Hy3GroupData::collapseExpansions() { Hy3Node* node = this->focused_child; - while (node->data.type == Hy3NodeType::Group - && node->data.as_group.expand_focused == ExpandFocusType::Stack) - { - node->data.as_group.expand_focused = ExpandFocusType::NotExpanded; - node = node->data.as_group.focused_child; + while (node->data.is_group() && node->data.as_group().expand_focused == ExpandFocusType::Stack) { + auto& group = node->data.as_group(); + group.expand_focused = ExpandFocusType::NotExpanded; + node = group.focused_child; } } @@ -79,64 +82,83 @@ void Hy3GroupData::setEphemeral(GroupEphemeralityOption ephemeral) { // Hy3NodeData // -Hy3NodeData::Hy3NodeData(): Hy3NodeData((CWindow*) nullptr) {} +Hy3NodeData::Hy3NodeData(Hy3GroupLayout layout) { this->data.emplace<1>(layout); } -Hy3NodeData::Hy3NodeData(CWindow* window): type(Hy3NodeType::Window) { this->as_window = window; } +Hy3NodeData::Hy3NodeData(PHLWINDOW window) { this->data.emplace<0>(window); } -Hy3NodeData::Hy3NodeData(Hy3GroupLayout layout): Hy3NodeData(Hy3GroupData(layout)) {} +Hy3NodeData::Hy3NodeData(Hy3GroupData group) { this->data.emplace<1>(std::move(group)); } -Hy3NodeData::Hy3NodeData(Hy3GroupData group): type(Hy3NodeType::Group) { - new (&this->as_group) Hy3GroupData(std::move(group)); -} - -Hy3NodeData::Hy3NodeData(Hy3NodeData&& from): type(from.type) { - switch (from.type) { - case Hy3NodeType::Window: this->as_window = from.as_window; break; - case Hy3NodeType::Group: new (&this->as_group) Hy3GroupData(std::move(from.as_group)); break; +Hy3NodeData::Hy3NodeData(Hy3NodeData&& node) { + if (std::holds_alternative(node.data)) { + this->data.emplace<0>(std::get(node.data)); + } else if (std::holds_alternative(node.data)) { + this->data.emplace<1>(std::move(std::get(node.data))); } } -Hy3NodeData::~Hy3NodeData() { - switch (this->type) { - case Hy3NodeType::Window: break; - case Hy3NodeType::Group: - this->as_group.~Hy3GroupData(); - - // who ever thought calling the dtor after a move was a good idea? - this->type = Hy3NodeType::Window; - break; - } -} - -Hy3NodeData& Hy3NodeData::operator=(CWindow* window) { +Hy3NodeData& Hy3NodeData::operator=(PHLWINDOW window) { *this = Hy3NodeData(window); - return *this; } Hy3NodeData& Hy3NodeData::operator=(Hy3GroupLayout layout) { *this = Hy3NodeData(layout); - return *this; } Hy3NodeData& Hy3NodeData::operator=(Hy3NodeData&& from) { - if (this->type == Hy3NodeType::Group) { - this->as_group.~Hy3GroupData(); - } - - this->type = from.type; - - switch (this->type) { - case Hy3NodeType::Window: this->as_window = from.as_window; break; - case Hy3NodeType::Group: new (&this->as_group) Hy3GroupData(std::move(from.as_group)); break; - } - + this->~Hy3NodeData(); + new (this) Hy3NodeData(std::move(from)); return *this; } bool Hy3NodeData::operator==(const Hy3NodeData& rhs) const { return this == &rhs; } +bool Hy3NodeData::valid() const { + if (std::holds_alternative(this->data)) { + return true; + } else if (std::holds_alternative(this->data)) { + return !std::get(this->data).expired(); + } else { + return false; + } +} + +Hy3NodeType Hy3NodeData::type() const { + if (std::holds_alternative(this->data)) { + return Hy3NodeType::Group; + } else if (std::holds_alternative(this->data)) { + return Hy3NodeType::Window; + } else { + throw std::runtime_error("Attempted to get Hy3NodeType of uninitialized Hy3NodeData"); + } +} + +bool Hy3NodeData::is_group() const { return this->type() == Hy3NodeType::Group; } + +bool Hy3NodeData::is_window() const { return this->type() == Hy3NodeType::Window; } + +Hy3GroupData& Hy3NodeData::as_group() { + if (std::holds_alternative(this->data)) { + return std::get(this->data); + } else { + throw std::runtime_error("Attempted to get group value of a non-group Hy3NodeData"); + } +} + +PHLWINDOW Hy3NodeData::as_window() { + if (std::holds_alternative(this->data)) { + auto& ref = std::get(this->data); + if (ref.expired()) { + throw std::runtime_error("Attempted to upgrade an expired Hy3NodeData of a window"); + } else { + return ref.lock(); + } + } else { + throw std::runtime_error("Attempted to get window value of a non-window Hy3NodeData"); + } +} + // Hy3Node // bool Hy3Node::operator==(const Hy3Node& rhs) const { return this->data == rhs.data; } @@ -144,10 +166,10 @@ bool Hy3Node::operator==(const Hy3Node& rhs) const { return this->data == rhs.da void Hy3Node::focus() { this->markFocused(); - switch (this->data.type) { + switch (this->data.type()) { case Hy3NodeType::Window: - this->data.as_window->setHidden(false); - g_pCompositor->focusWindow(this->data.as_window); + this->data.as_window()->setHidden(false); + g_pCompositor->focusWindow(this->data.as_window()); break; case Hy3NodeType::Group: g_pCompositor->focusWindow(nullptr); @@ -156,39 +178,41 @@ void Hy3Node::focus() { } } -CWindow* Hy3Node::bringToTop() { - switch (this->data.type) { - case Hy3NodeType::Window: +PHLWINDOW Hy3Node::bringToTop() { + switch (this->data.type()) { + case Hy3NodeType::Window: { this->markFocused(); - this->data.as_window->setHidden(false); - - return this->data.as_window; - case Hy3NodeType::Group: - if (this->data.as_group.layout == Hy3GroupLayout::Tabbed) { - if (this->data.as_group.focused_child != nullptr) { - return this->data.as_group.focused_child->bringToTop(); + auto window = this->data.as_window(); + window->setHidden(false); + return window; + } + case Hy3NodeType::Group: { + auto& group = this->data.as_group(); + if (group.layout == Hy3GroupLayout::Tabbed) { + if (group.focused_child != nullptr) { + return group.focused_child->bringToTop(); } } else { - for (auto* node: this->data.as_group.children) { - auto* window = node->bringToTop(); + for (auto* node: group.children) { + auto window = node->bringToTop(); if (window != nullptr) return window; } } return nullptr; - default: return nullptr; + } } } void Hy3Node::focusWindow() { - auto* window = this->bringToTop(); + auto window = this->bringToTop(); if (window != nullptr) g_pCompositor->focusWindow(window); } void markGroupFocusedRecursive(Hy3GroupData& group) { group.group_focused = true; for (auto& child: group.children) { - if (child->data.type == Hy3NodeType::Group) markGroupFocusedRecursive(child->data.as_group); + if (child->data.is_group()) markGroupFocusedRecursive(child->data.as_group()); } } @@ -200,14 +224,15 @@ void Hy3Node::markFocused() { while (root->parent != nullptr) root = root->parent; // update focus - if (this->data.type == Hy3NodeType::Group) { - markGroupFocusedRecursive(this->data.as_group); + if (this->data.is_group()) { + markGroupFocusedRecursive(this->data.as_group()); } auto* node2 = node; while (node2->parent != nullptr) { - node2->parent->data.as_group.focused_child = node2; - node2->parent->data.as_group.group_focused = false; + auto& group = node2->parent->data.as_group(); + group.focused_child = node2; + group.group_focused = false; node2 = node2->parent; } @@ -215,10 +240,10 @@ void Hy3Node::markFocused() { } void Hy3Node::raiseToTop() { - switch (this->data.type) { - case Hy3NodeType::Window: g_pCompositor->changeWindowZOrder(this->data.as_window, true); break; + switch (this->data.type()) { + case Hy3NodeType::Window: g_pCompositor->changeWindowZOrder(this->data.as_window(), true); break; case Hy3NodeType::Group: - for (auto* child: this->data.as_group.children) { + for (auto* child: this->data.as_group().children) { child->raiseToTop(); } break; @@ -226,21 +251,19 @@ void Hy3Node::raiseToTop() { } Hy3Node* Hy3Node::getFocusedNode(bool ignore_group_focus, bool stop_at_expanded) { - switch (this->data.type) { + switch (this->data.type()) { case Hy3NodeType::Window: return this; - case Hy3NodeType::Group: - if (this->data.as_group.focused_child == nullptr - || (!ignore_group_focus && this->data.as_group.group_focused) - || (stop_at_expanded && this->data.as_group.expand_focused != ExpandFocusType::NotExpanded)) + case Hy3NodeType::Group: { + auto& group = this->data.as_group(); + + if (group.focused_child == nullptr || (!ignore_group_focus && group.group_focused) + || (stop_at_expanded && group.expand_focused != ExpandFocusType::NotExpanded)) { return this; } else { - return this->data.as_group.focused_child->getFocusedNode( - ignore_group_focus, - stop_at_expanded - ); + return group.focused_child->getFocusedNode(ignore_group_focus, stop_at_expanded); } - default: return nullptr; + } } } @@ -248,9 +271,8 @@ bool Hy3Node::isIndirectlyFocused() { Hy3Node* node = this; while (node->parent != nullptr) { - if (!node->parent->data.as_group.group_focused - && node->parent->data.as_group.focused_child != node) - return false; + auto& group = node->parent->data.as_group(); + if (!group.group_focused && group.focused_child != node) return false; node = node->parent; } @@ -262,7 +284,7 @@ Hy3Node& Hy3Node::getExpandActor() { Hy3Node* node = this; while (node->parent != nullptr - && node->parent->data.as_group.expand_focused != ExpandFocusType::NotExpanded) + && node->parent->data.as_group().expand_focused != ExpandFocusType::NotExpanded) node = node->parent; return *node; @@ -289,17 +311,18 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { ); // clang-format on - if (this->data.type == Hy3NodeType::Window && this->data.as_window->m_bIsFullscreen) { + if (this->data.is_window() && this->data.as_window()->m_bIsFullscreen) { + auto window = this->data.as_window(); auto* monitor = g_pCompositor->getMonitorFromID(this->workspace->m_iMonitorID); if (this->workspace->m_efFullscreenMode == FULLSCREEN_FULL) { - this->data.as_window->m_vRealPosition = monitor->vecPosition; - this->data.as_window->m_vRealSize = monitor->vecSize; + window->m_vRealPosition = monitor->vecPosition; + window->m_vRealSize = monitor->vecSize; return; } Hy3Node fake_node = { - .data = this->data.as_window, + .data = window, .position = monitor->vecPosition + monitor->vecReservedTopLeft, .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, .gap_topleft_offset = gap_topleft_offset, @@ -321,16 +344,16 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { double tab_height_offset = *tab_bar_height + *tab_bar_padding; - if (this->data.type == Hy3NodeType::Window) { - this->data.as_window->setHidden(this->hidden); + if (this->data.is_window()) { + this->data.as_window()->setHidden(this->hidden); this->layout->applyNodeDataToWindow(this, no_animation); return; } - auto* group = &this->data.as_group; + auto& group = this->data.as_group(); double constraint; - switch (group->layout) { + switch (group.layout) { case Hy3GroupLayout::SplitH: constraint = tsize.x - gap_topleft_offset.x - gap_bottomright_offset.x; break; @@ -340,34 +363,34 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { case Hy3GroupLayout::Tabbed: break; } - auto expand_focused = group->expand_focused != ExpandFocusType::NotExpanded; + auto expand_focused = group.expand_focused != ExpandFocusType::NotExpanded; bool directly_contains_expanded = expand_focused - && (group->focused_child->data.type == Hy3NodeType::Window - || group->focused_child->data.as_group.expand_focused == ExpandFocusType::NotExpanded); + && (group.focused_child->data.is_window() + || group.focused_child->data.as_group().expand_focused == ExpandFocusType::NotExpanded); - auto child_count = group->children.size(); + auto child_count = group.children.size(); double ratio_mul = - group->layout != Hy3GroupLayout::Tabbed ? child_count <= 0 ? 0 : constraint / child_count : 0; + group.layout != Hy3GroupLayout::Tabbed ? child_count <= 0 ? 0 : constraint / child_count : 0; double offset = 0; - if (group->layout == Hy3GroupLayout::Tabbed && group->focused_child != nullptr - && !group->focused_child->hidden) + if (group.layout == Hy3GroupLayout::Tabbed && group.focused_child != nullptr + && !group.focused_child->hidden) { - group->focused_child->setHidden(false); + group.focused_child->setHidden(false); auto box = CBox {tpos.x, tpos.y, tsize.x, tsize.y}; g_pHyprRenderer->damageBox(&box); } - if (group->expand_focused == ExpandFocusType::Latch) { - auto* expanded_node = group->focused_child; + if (group.expand_focused == ExpandFocusType::Latch) { + auto* expanded_node = group.focused_child; - while (expanded_node != nullptr && expanded_node->data.type == Hy3NodeType::Group - && expanded_node->data.as_group.expand_focused != ExpandFocusType::NotExpanded) + while (expanded_node != nullptr && expanded_node->data.is_group() + && expanded_node->data.as_group().expand_focused != ExpandFocusType::NotExpanded) { - expanded_node = expanded_node->data.as_group.focused_child; + expanded_node = expanded_node->data.as_group().focused_child; } if (expanded_node == nullptr) { @@ -390,9 +413,9 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { expanded_node->recalcSizePosRecursive(no_animation); } - for (auto* child: group->children) { - if (directly_contains_expanded && child == group->focused_child) { - switch (group->layout) { + for (auto* child: group.children) { + if (directly_contains_expanded && child == group.focused_child) { + switch (group.layout) { case Hy3GroupLayout::SplitH: offset += child->size_ratio * ratio_mul; break; case Hy3GroupLayout::SplitV: offset += child->size_ratio * ratio_mul; break; case Hy3GroupLayout::Tabbed: break; @@ -401,7 +424,7 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { continue; } - switch (group->layout) { + switch (group.layout) { case Hy3GroupLayout::SplitH: child->position.x = tpos.x + offset; child->size.x = child->size_ratio * ratio_mul; @@ -410,17 +433,17 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { child->size.y = tsize.y; child->hidden = this->hidden || expand_focused; - if (group->children.size() == 1) { + if (group.children.size() == 1) { child->gap_topleft_offset = gap_topleft_offset; child->gap_bottomright_offset = gap_bottomright_offset; child->size.x = tsize.x; if (this->parent != nullptr) child->gap_bottomright_offset.x += *group_inset; - } else if (child == group->children.front()) { + } else if (child == group.children.front()) { child->gap_topleft_offset = gap_topleft_offset; child->gap_bottomright_offset = Vector2D(0, gap_bottomright_offset.y); child->size.x += gap_topleft_offset.x; offset += gap_topleft_offset.x; - } else if (child == group->children.back()) { + } else if (child == group.children.back()) { child->gap_topleft_offset = Vector2D(0, gap_topleft_offset.y); child->gap_bottomright_offset = gap_bottomright_offset; child->size.x += gap_bottomright_offset.x; @@ -439,17 +462,17 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { child->size.x = tsize.x; child->hidden = this->hidden || expand_focused; - if (group->children.size() == 1) { + if (group.children.size() == 1) { child->gap_topleft_offset = gap_topleft_offset; child->gap_bottomright_offset = gap_bottomright_offset; child->size.y = tsize.y; if (this->parent != nullptr) child->gap_bottomright_offset.y += *group_inset; - } else if (child == group->children.front()) { + } else if (child == group.children.front()) { child->gap_topleft_offset = gap_topleft_offset; child->gap_bottomright_offset = Vector2D(gap_bottomright_offset.x, 0); child->size.y += gap_topleft_offset.y; offset += gap_topleft_offset.y; - } else if (child == group->children.back()) { + } else if (child == group.children.back()) { child->gap_topleft_offset = Vector2D(gap_topleft_offset.x, 0); child->gap_bottomright_offset = gap_bottomright_offset; child->size.y += gap_bottomright_offset.y; @@ -463,7 +486,7 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { case Hy3GroupLayout::Tabbed: child->position = tpos; child->size = tsize; - child->hidden = this->hidden || expand_focused || group->focused_child != child; + child->hidden = this->hidden || expand_focused || group.focused_child != child; child->gap_topleft_offset = Vector2D(gap_topleft_offset.x, gap_topleft_offset.y + tab_height_offset); @@ -478,18 +501,18 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { } struct FindTopWindowInNodeResult { - CWindow* window = nullptr; + PHLWINDOW window = nullptr; size_t index = 0; }; void findTopWindowInNode(Hy3Node& node, FindTopWindowInNodeResult& result) { - switch (node.data.type) { + switch (node.data.type()) { case Hy3NodeType::Window: { - auto* window = node.data.as_window; + auto window = node.data.as_window(); auto& windows = g_pCompositor->m_vWindows; for (; result.index < windows.size(); result.index++) { - if (&*windows[result.index] == window) { + if (windows[result.index] == window) { result.window = window; break; } @@ -497,7 +520,7 @@ void findTopWindowInNode(Hy3Node& node, FindTopWindowInNodeResult& result) { } break; case Hy3NodeType::Group: { - auto& group = node.data.as_group; + auto& group = node.data.as_group(); if (group.layout == Hy3GroupLayout::Tabbed) { if (group.focused_child != nullptr) findTopWindowInNode(*group.focused_child, result); @@ -511,8 +534,8 @@ void findTopWindowInNode(Hy3Node& node, FindTopWindowInNodeResult& result) { } void Hy3Node::updateTabBar(bool no_animation) { - if (this->data.type == Hy3NodeType::Group) { - auto& group = this->data.as_group; + if (this->data.type() == Hy3NodeType::Group) { + auto& group = this->data.as_group(); if (group.layout == Hy3GroupLayout::Tabbed) { if (group.tab_bar == nullptr) group.tab_bar = &this->layout->tab_groups.emplace_back(*this); @@ -539,13 +562,12 @@ void Hy3Node::updateTabBarRecursive() { } void Hy3Node::updateDecos() { - switch (this->data.type) { + switch (this->data.type()) { case Hy3NodeType::Window: - if (this->data.as_window->m_bIsMapped) - g_pCompositor->updateWindowAnimatedDecorationValues(this->data.as_window); + g_pCompositor->updateWindowAnimatedDecorationValues(this->data.as_window()); break; case Hy3NodeType::Group: - for (auto* child: this->data.as_group.children) { + for (auto* child: this->data.as_group().children) { child->updateDecos(); } @@ -554,21 +576,22 @@ void Hy3Node::updateDecos() { } std::string Hy3Node::getTitle() { - switch (this->data.type) { - case Hy3NodeType::Window: return this->data.as_window->m_szTitle; + switch (this->data.type()) { + case Hy3NodeType::Window: return this->data.as_window()->m_szTitle; case Hy3NodeType::Group: std::string title; + auto& group = this->data.as_group(); - switch (this->data.as_group.layout) { + switch (group.layout) { case Hy3GroupLayout::SplitH: title = "[H] "; break; case Hy3GroupLayout::SplitV: title = "[V] "; break; case Hy3GroupLayout::Tabbed: title = "[T] "; break; } - if (this->data.as_group.focused_child == nullptr) { + if (group.focused_child == nullptr) { title += "Group"; } else { - title += this->data.as_group.focused_child->getTitle(); + title += group.focused_child->getTitle(); } return title; @@ -578,33 +601,31 @@ std::string Hy3Node::getTitle() { } bool Hy3Node::isUrgent() { - switch (this->data.type) { - case Hy3NodeType::Window: return this->data.as_window->m_bIsUrgent; + switch (this->data.type()) { + case Hy3NodeType::Window: return this->data.as_window()->m_bIsUrgent; case Hy3NodeType::Group: - for (auto* child: this->data.as_group.children) { + for (auto* child: this->data.as_group().children) { if (child->isUrgent()) return true; } return false; - default: return false; } } void Hy3Node::setHidden(bool hidden) { this->hidden = hidden; - if (this->data.type == Hy3NodeType::Group) { - for (auto* child: this->data.as_group.children) { + if (this->data.is_group()) { + for (auto* child: this->data.as_group().children) { child->setHidden(hidden); } } } Hy3Node* Hy3Node::findNodeForTabGroup(Hy3TabGroup& tab_group) { - if (this->data.type == Hy3NodeType::Group) { + if (this->data.is_group()) { if (this->hidden) return nullptr; - - auto& group = this->data.as_group; + auto& group = this->data.as_group(); if (group.layout == Hy3GroupLayout::Tabbed && group.tab_bar == &tab_group) { return this; @@ -619,11 +640,11 @@ Hy3Node* Hy3Node::findNodeForTabGroup(Hy3TabGroup& tab_group) { return nullptr; } -void Hy3Node::appendAllWindows(std::vector& list) { - switch (this->data.type) { - case Hy3NodeType::Window: list.push_back(this->data.as_window); break; +void Hy3Node::appendAllWindows(std::vector& list) { + switch (this->data.type()) { + case Hy3NodeType::Window: list.push_back(this->data.as_window()); break; case Hy3NodeType::Group: - for (auto* child: this->data.as_group.children) { + for (auto* child: this->data.as_group().children) { child->appendAllWindows(list); } break; @@ -633,12 +654,12 @@ void Hy3Node::appendAllWindows(std::vector& list) { std::string Hy3Node::debugNode() { std::stringstream buf; std::string addr = "0x" + std::to_string((size_t) this); - switch (this->data.type) { + switch (this->data.type()) { case Hy3NodeType::Window: buf << "window("; buf << std::hex << this; buf << ") [hypr "; - buf << this->data.as_window; + buf << this->data.as_window(); buf << "] size ratio: "; buf << this->size_ratio; break; @@ -647,7 +668,8 @@ std::string Hy3Node::debugNode() { buf << std::hex << this; buf << ") ["; - switch (this->data.as_group.layout) { + auto& group = this->data.as_group(); + switch (group.layout) { case Hy3GroupLayout::SplitH: buf << "splith"; break; case Hy3GroupLayout::SplitV: buf << "splitv"; break; case Hy3GroupLayout::Tabbed: buf << "tabs"; break; @@ -656,19 +678,19 @@ std::string Hy3Node::debugNode() { buf << "] size ratio: "; buf << this->size_ratio; - if (this->data.as_group.expand_focused != ExpandFocusType::NotExpanded) { + if (group.expand_focused != ExpandFocusType::NotExpanded) { buf << ", has-expanded"; } - if (this->data.as_group.ephemeral) { + if (group.ephemeral) { buf << ", ephemeral"; } - if (this->data.as_group.containment) { + if (group.containment) { buf << ", containment"; } - for (auto* child: this->data.as_group.children) { + for (auto* child: group.children) { buf << "\n|-"; if (child == nullptr) { buf << "nullptr"; @@ -694,8 +716,8 @@ Hy3Node* Hy3Node::removeFromParentRecursive(Hy3Node** expand_actor) { if (this->parent != nullptr) { auto& actor = this->getExpandActor(); - if (actor.data.type == Hy3NodeType::Group) { - actor.data.as_group.collapseExpansions(); + if (actor.data.is_group()) { + actor.data.as_group().collapseExpansions(); if (expand_actor != nullptr) *expand_actor = &actor; } } @@ -708,7 +730,7 @@ Hy3Node* Hy3Node::removeFromParentRecursive(Hy3Node** expand_actor) { auto* child = parent; parent = parent->parent; - auto& group = parent->data.as_group; + auto& group = parent->data.as_group(); if (group.children.size() > 2) { auto iter = std::find(group.children.begin(), group.children.end(), child); @@ -778,11 +800,12 @@ Hy3Node* Hy3Node::intoGroup(Hy3GroupLayout layout, GroupEphemeralityOption ephem swapData(*this, *node); this->data = layout; - this->data.as_group.children.push_back(node); - this->data.as_group.group_focused = false; - this->data.as_group.focused_child = node; - this->data.as_group.ephemeral = ephemeral == GroupEphemeralityOption::Ephemeral - || ephemeral == GroupEphemeralityOption::ForceEphemeral; + auto& group = this->data.as_group(); + group.children.push_back(node); + group.group_focused = false; + group.focused_child = node; + group.ephemeral = ephemeral == GroupEphemeralityOption::Ephemeral + || ephemeral == GroupEphemeralityOption::ForceEphemeral; this->recalcSizePosRecursive(); this->updateTabBarRecursive(); @@ -790,15 +813,14 @@ Hy3Node* Hy3Node::intoGroup(Hy3GroupLayout layout, GroupEphemeralityOption ephem } bool Hy3Node::swallowGroups(Hy3Node* into) { - if (into == nullptr || into->data.type != Hy3NodeType::Group - || into->data.as_group.children.size() != 1) + if (into == nullptr || into->data.is_window() || into->data.as_group().children.size() != 1) return false; - auto* child = into->data.as_group.children.front(); + auto* child = into->data.as_group().children.front(); // a lot of segfaulting happens once the assumption that the root node is a // group is wrong. - if (into->parent == nullptr && child->data.type != Hy3NodeType::Group) return false; + if (into->parent == nullptr && child->data.is_window()) return false; hy3_log(TRACE, "swallowing node {:x} into node {:x}", (uintptr_t) child, (uintptr_t) into); @@ -819,7 +841,7 @@ Hy3Node* getOuterChild(Hy3GroupData& group, ShiftDirection direction) { } Hy3Node* Hy3Node::getImmediateSibling(ShiftDirection direction) { - const auto& group = this->parent->data.as_group; + const auto& group = this->parent->data.as_group(); auto iter = std::find(group.children.begin(), group.children.end(), this); @@ -864,7 +886,7 @@ Hy3Node* Hy3Node::findNeighbor(ShiftDirection direction) { Hy3Node* sibling = nullptr; while (sibling == nullptr && current_node->parent != nullptr) { - auto& parent_group = current_node->parent->data.as_group; + auto& parent_group = current_node->parent->data.as_group(); if (parent_group.layout != Hy3GroupLayout::Tabbed && getAxis(parent_group.layout) == getAxis(direction)) @@ -895,7 +917,7 @@ int directionToIteratorIncrement(ShiftDirection direction) { void Hy3Node::resize(ShiftDirection direction, double delta, bool no_animation) { auto& parent_node = this->parent; - auto& containing_group = parent_node->data.as_group; + auto& containing_group = parent_node->data.as_group(); if (containing_group.layout != Hy3GroupLayout::Tabbed && getAxis(direction) == getAxis(containing_group.layout)) @@ -936,14 +958,14 @@ void Hy3Node::swapData(Hy3Node& a, Hy3Node& b) { a.data = std::move(b.data); b.data = std::move(aData); - if (a.data.type == Hy3NodeType::Group) { - for (auto child: a.data.as_group.children) { + if (a.data.is_group()) { + for (auto child: a.data.as_group().children) { child->parent = &a; } } - if (b.data.type == Hy3NodeType::Group) { - for (auto child: b.data.as_group.children) { + if (b.data.is_group()) { + for (auto child: b.data.as_group().children) { child->parent = &b; } } diff --git a/src/Hy3Node.hpp b/src/Hy3Node.hpp index 772d01f..7a52f3c 100644 --- a/src/Hy3Node.hpp +++ b/src/Hy3Node.hpp @@ -4,8 +4,9 @@ struct Hy3Node; struct Hy3GroupData; enum class Hy3GroupLayout; -#include +#include +#include #include #include "Hy3Layout.hpp" @@ -47,7 +48,6 @@ struct Hy3GroupData { void setLayout(Hy3GroupLayout layout); void setEphemeral(GroupEphemeralityOption ephemeral); -private: Hy3GroupData(Hy3GroupData&&); Hy3GroupData(const Hy3GroupData&) = delete; @@ -56,26 +56,28 @@ private: class Hy3NodeData { public: - Hy3NodeType type; - union { - Hy3GroupData as_group; - CWindow* as_window; - }; - - Hy3NodeData(); - Hy3NodeData(CWindow* window); + Hy3NodeData() = default; + Hy3NodeData(Hy3GroupData); + Hy3NodeData(PHLWINDOW window); Hy3NodeData(Hy3GroupLayout layout); - ~Hy3NodeData(); + Hy3NodeData(Hy3NodeData&&); + ~Hy3NodeData() = default; - Hy3NodeData& operator=(CWindow*); + Hy3NodeData& operator=(PHLWINDOW); Hy3NodeData& operator=(Hy3GroupLayout); + Hy3NodeData& operator=(Hy3NodeData&&); bool operator==(const Hy3NodeData&) const; - // private: - I give up, C++ wins - Hy3NodeData(Hy3GroupData); - Hy3NodeData(Hy3NodeData&&); - Hy3NodeData& operator=(Hy3NodeData&&); + bool valid() const; + Hy3NodeType type() const; + bool is_window() const; + bool is_group() const; + Hy3GroupData& as_group(); + PHLWINDOW as_window(); + +private: + std::variant data; }; struct Hy3Node { @@ -95,7 +97,7 @@ struct Hy3Node { void focus(); void focusWindow(); - CWindow* bringToTop(); + PHLWINDOW bringToTop(); void markFocused(); void raiseToTop(); Hy3Node* getFocusedNode(bool ignore_group_focus = false, bool stop_at_expanded = false); @@ -115,7 +117,7 @@ struct Hy3Node { void setHidden(bool); Hy3Node* findNodeForTabGroup(Hy3TabGroup&); - void appendAllWindows(std::vector&); + void appendAllWindows(std::vector&); std::string debugNode(); // Remove this node from its parent, deleting the parent if it was diff --git a/src/SelectionHook.cpp b/src/SelectionHook.cpp index 603ede6..ae5c051 100644 --- a/src/SelectionHook.cpp +++ b/src/SelectionHook.cpp @@ -6,15 +6,15 @@ namespace selection_hook { inline CFunctionHook* g_LastSelectionHook = nullptr; -void hook_updateDecos(void* thisptr, CWindow* window) { +void hook_updateDecos(void* thisptr, PHLWINDOW window) { bool explicitly_selected = g_Hy3Layout->shouldRenderSelected(window); - auto* lastWindow = g_pCompositor->m_pLastWindow; + auto lastWindow = g_pCompositor->m_pLastWindow; if (explicitly_selected) { g_pCompositor->m_pLastWindow = window; } - ((void (*)(void*, CWindow*)) g_LastSelectionHook->m_pOriginal)(thisptr, window); + ((void (*)(void*, PHLWINDOW)) g_LastSelectionHook->m_pOriginal)(thisptr, window); if (explicitly_selected) { g_pCompositor->m_pLastWindow = lastWindow; diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index d8005b4..86eb679 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include #include #include @@ -328,7 +330,7 @@ exitloop: // set stats from node data auto* parent = (*node)->parent; - auto& parent_group = parent->data.as_group; + auto& parent_group = parent->data.as_group(); entry->setFocused( parent_group.focused_child == *node @@ -433,11 +435,11 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { if (warp) this->size.warp(); } - this->bar.updateNodeList(node.data.as_group.children); + this->bar.updateNodeList(node.data.as_group().children); this->bar.updateAnimations(warp); - if (node.data.as_group.focused_child != nullptr) { - this->updateStencilWindows(*node.data.as_group.focused_child); + if (node.data.as_group().focused_child != nullptr) { + this->updateStencilWindows(*node.data.as_group().focused_child); } } @@ -539,8 +541,9 @@ void Hy3TabGroup::renderTabBar() { glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - for (auto* window: this->stencil_windows) { - if (!g_pCompositor->windowExists(window)) continue; + for (auto windowref: this->stencil_windows) { + if (!valid(windowref)) continue; + auto window = windowref.lock(); auto wpos = window->m_vRealPosition.value() - monitor->vecPosition; auto wsize = window->m_vRealSize.value(); @@ -603,11 +606,11 @@ void Hy3TabGroup::renderTabBar() { } } -void findOverlappingWindows(Hy3Node& node, float height, std::vector& windows) { - switch (node.data.type) { - case Hy3NodeType::Window: windows.push_back(node.data.as_window); break; +void findOverlappingWindows(Hy3Node& node, float height, std::vector& windows) { + switch (node.data.type()) { + case Hy3NodeType::Window: windows.push_back(node.data.as_window()); break; case Hy3NodeType::Group: - auto& group = node.data.as_group; + auto& group = node.data.as_group(); switch (group.layout) { case Hy3GroupLayout::SplitH: diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 3d77624..12117f3 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -85,7 +85,7 @@ private: class Hy3TabGroup { public: - CWindow* target_window = nullptr; + PHLWINDOW target_window = nullptr; PHLWORKSPACE workspace = nullptr; bool hidden = false; Hy3TabBar bar; @@ -102,7 +102,7 @@ public: void renderTabBar(); private: - std::vector stencil_windows; + std::vector stencil_windows; Vector2D last_pos; Vector2D last_size; From 2b1dcba1983594095adade4ae5e2f70a3d155fd0 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 29 Apr 2024 16:54:01 -0700 Subject: [PATCH 13/45] fixup: add manifest entry for hyprland v0.39.0 Closes #101 --- hyprpm.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/hyprpm.toml b/hyprpm.toml index 5257db2..339e1ef 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -8,6 +8,7 @@ commit_pins = [ ["c5e28ebcfe00a510922779b2c568cfa52a317445", "8ac36f3954619a9a5c1a1bb3296f782452987e82"], ["3875679755014997776e091ff8903acfb311dd2f", "6f9719291386d5e3baad211420d60e54e9967ee6"], ["360ede79d124ffdeebbe8401f1ac4bc0dbec2c91", "6f9719291386d5e3baad211420d60e54e9967ee6"], + ["e93fbd7c4f991cb8ef03e433ccc4d43587923e15", "6f9719291386d5e3baad211420d60e54e9967ee6"], ["fe7b748eb668136dd0558b7c8279bfcd7ab4d759", "6f9719291386d5e3baad211420d60e54e9967ee6"] ] From bc25b2a87fa7528ec4242f952a66556e1dda782b Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 5 May 2024 13:52:44 -0700 Subject: [PATCH 14/45] fixup: fix breakage after hyprland#5883 --- flake.lock | 70 ++++++++++++++++++----------------------------- flake.nix | 2 +- src/Hy3Layout.cpp | 8 +++--- 3 files changed, 31 insertions(+), 49 deletions(-) diff --git a/flake.lock b/flake.lock index 50d25e8..4364474 100644 --- a/flake.lock +++ b/flake.lock @@ -32,45 +32,47 @@ "hyprland": { "inputs": { "hyprcursor": "hyprcursor", - "hyprland-protocols": "hyprland-protocols", "hyprlang": "hyprlang", "hyprwayland-scanner": "hyprwayland-scanner", "nixpkgs": "nixpkgs", "systems": "systems", - "wlroots": "wlroots", "xdph": "xdph" }, "locked": { - "lastModified": 1714409407, - "narHash": "sha256-gc10Ag5O/s+EE24JZUXTpH4ogRsSyAfdgr7OvSNhQ8s=", - "owner": "hyprwm", - "repo": "Hyprland", - "rev": "f2b03e9679bc1a091fecffd98b50a4179b5c7d43", - "type": "github" + "lastModified": 1714933694, + "narHash": "sha256-gziEBZF1wmBBw3v0Ang3nN3QwoQWtFmBIORODJt38TE=", + "ref": "refs/heads/main", + "rev": "cddeec47a1fc0e70d8598fd10c29cd0e9489999f", + "revCount": 4617, + "submodules": true, + "type": "git", + "url": "https://github.com/hyprwm/Hyprland" }, "original": { - "owner": "hyprwm", - "repo": "Hyprland", - "type": "github" + "submodules": true, + "type": "git", + "url": "https://github.com/hyprwm/Hyprland" } }, "hyprland-protocols": { "inputs": { "nixpkgs": [ "hyprland", + "xdph", "nixpkgs" ], "systems": [ "hyprland", + "xdph", "systems" ] }, "locked": { - "lastModified": 1691753796, - "narHash": "sha256-zOEwiWoXk3j3+EoF3ySUJmberFewWlagvewDRuWYAso=", + "lastModified": 1714869498, + "narHash": "sha256-vbLVOWvQqo4n1yvkg/Q70VTlPbMmTiCQfNTgcWDCfJM=", "owner": "hyprwm", "repo": "hyprland-protocols", - "rev": "0c2ce70625cb30aef199cb388f99e19a61a6ce03", + "rev": "e06482e0e611130cd1929f75e8c1cf679e57d161", "type": "github" }, "original": { @@ -116,11 +118,11 @@ ] }, "locked": { - "lastModified": 1714171579, - "narHash": "sha256-eaWDIvt8ufUKKz3Lc2a3PyemLJG1m9RYlF+HP3hWbaw=", + "lastModified": 1714755542, + "narHash": "sha256-D0pg+ZRwrt4lavZ97Ca8clsgbPA3duLj8iEM7riaIFY=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "126dad854f22fe30e6b82cd21808e76903d90ac5", + "rev": "1270ebaa539e56d61b708c24b072b09cbbd3a828", "type": "github" }, "original": { @@ -131,11 +133,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1713714899, - "narHash": "sha256-+z/XjO3QJs5rLE5UOf015gdVauVRQd2vZtsFkaXBq2Y=", + "lastModified": 1714253743, + "narHash": "sha256-mdTQw2XlariysyScCv2tTE45QSU9v/ezLcHJ22f0Nxc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6143fc5eeb9c4f00163267708e26191d1e918932", + "rev": "58a1abdbae3217ca6b702f03d3b35125d88a2994", "type": "github" }, "original": { @@ -165,29 +167,9 @@ "type": "github" } }, - "wlroots": { - "flake": false, - "locked": { - "lastModified": 1713731601, - "narHash": "sha256-bdcKdtLkusvv85DNuJsajZLFeq7bXp+x5AGP1Sd4wD8=", - "owner": "hyprwm", - "repo": "wlroots-hyprland", - "rev": "5c1d51c5a2793480f5b6c4341ad0797052aec2ea", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "wlroots-hyprland", - "rev": "5c1d51c5a2793480f5b6c4341ad0797052aec2ea", - "type": "github" - } - }, "xdph": { "inputs": { - "hyprland-protocols": [ - "hyprland", - "hyprland-protocols" - ], + "hyprland-protocols": "hyprland-protocols", "hyprlang": [ "hyprland", "hyprlang" @@ -202,11 +184,11 @@ ] }, "locked": { - "lastModified": 1713724432, - "narHash": "sha256-dtU1y4oj/0Y42oauzm93ucFg1AoqETnQ21bmXTIUng0=", + "lastModified": 1714060055, + "narHash": "sha256-j43TS9wv9luaAlpxcxw0sjxkbcc2mGANVR2RYgo3RCw=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "9ace6f969ce495185df34cc6254fb9d297765478", + "rev": "0fe840441e43da12cd7865ed9aa8cdc35a8da85a", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index a375308..bf2c928 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "github:hyprwm/Hyprland"; + hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1"; }; outputs = { self, hyprland, ... }: let diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 4bfcca8..348e1fc 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -11,10 +11,10 @@ #include "SelectionHook.hpp" #include "globals.hpp" -std::shared_ptr renderHookPtr; -std::shared_ptr windowTitleHookPtr; -std::shared_ptr urgentHookPtr; -std::shared_ptr tickHookPtr; +SP renderHookPtr; +SP windowTitleHookPtr; +SP urgentHookPtr; +SP tickHookPtr; bool performContainment(Hy3Node& node, bool contained, PHLWINDOW& window) { if (node.data.is_group()) { From 311939d4439033cfdeb77dbc1dba0d689cef750b Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 5 May 2024 17:47:55 -0700 Subject: [PATCH 15/45] feat: add cursor warping support to `hy3:movefocus` --- CHANGELOG.md | 4 ++++ README.md | 4 +++- src/Hy3Layout.cpp | 47 ++++++++++++++++++++++++++++++++++----------- src/Hy3Layout.hpp | 3 ++- src/Hy3Node.cpp | 17 +++++++++++----- src/Hy3Node.hpp | 2 +- src/dispatchers.cpp | 17 +++++++++++++--- 7 files changed, 72 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec064b4..655cedf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Upcoming + +- Added cursor warping options for `hy3:movefocus`. + ## hl0.37.1 and before - Added `no_gaps_when_only = 2` diff --git a/README.md b/README.md index ef2dda8..4b73234 100644 --- a/README.md +++ b/README.md @@ -317,8 +317,10 @@ plugin { - `toggletab` will untab if group is tabbed, and tab if group is untabbed - `opposite` will toggle between horizontal and vertical layouts if the group is not tabbed. - `hy3:setephemeral, ` - change the ephemerality of the group the node belongs to - - `hy3:movefocus, , [visible]` - move the focus left, up, down, or right + - `hy3:movefocus, , [visible], [warp | nowarp]` - move the focus left, up, down, or right - `visible` - only move between visible nodes, not hidden tabs + - `warp` - warp the mouse to the selected window, even if `general:no_cursor_warps` is true. + - `nowarp` - does not warp the mouse to the selected window, even if `general:no_cursor_warps` is false. - `hy3:movewindow, , [once], [visible]` - move a window left, up, down, or right - `once` - only move directly to the neighboring group, without moving into any of its subgroups - `visible` - only move between visible nodes, not hidden tabs diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 348e1fc..bc5dc5d 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -8,6 +8,7 @@ #include #include "Hy3Layout.hpp" +#include "Hy3Node.hpp" #include "SelectionHook.hpp" #include "globals.hpp" @@ -878,7 +879,12 @@ void Hy3Layout::shiftWindow( this->shiftNode(*node, direction, once, visible); } -void Hy3Layout::shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection direction, bool visible) { +void Hy3Layout::shiftFocus( + const PHLWORKSPACE& workspace, + ShiftDirection direction, + bool visible, + bool warp +) { auto current_window = g_pCompositor->m_pLastWindow.lock(); if (current_window != nullptr) { @@ -893,7 +899,10 @@ void Hy3Layout::shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection directi : 'r' ); - if (next_window != nullptr) g_pCompositor->focusWindow(next_window); + if (next_window != nullptr) { + g_pCompositor->focusWindow(next_window); + if (warp) Hy3Layout::warpCursorToBox(next_window->m_vPosition, next_window->m_vSize); + } return; } } @@ -904,7 +913,13 @@ void Hy3Layout::shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection directi auto* target = this->shiftOrGetFocus(*node, direction, false, false, visible); if (target != nullptr) { - target->focus(); + if (warp) { + // don't warp for nodes in the same tab + warp = node->parent == nullptr || target->parent == nullptr || node->parent != target->parent + || node->parent->data.as_group().layout != Hy3GroupLayout::Tabbed; + } + + target->focus(warp); while (target->parent != nullptr) target = target->parent; target->recalcSizePosRecursive(); } @@ -1007,24 +1022,24 @@ void Hy3Layout::changeFocus(const PHLWORKSPACE& workspace, FocusShift shift) { node = node->parent; } - node->focus(); + node->focus(false); return; case FocusShift::Raise: if (node->parent == nullptr) goto bottom; else { - node->parent->focus(); + node->parent->focus(false); } return; case FocusShift::Lower: if (node->data.is_group() && node->data.as_group().focused_child != nullptr) - node->data.as_group().focused_child->focus(); + node->data.as_group().focused_child->focus(false); return; case FocusShift::Tab: // make sure we go up at least one level if (node->parent != nullptr) node = node->parent; while (node->parent != nullptr) { if (node->data.as_group().layout == Hy3GroupLayout::Tabbed) { - node->focus(); + node->focus(false); return; } @@ -1036,7 +1051,7 @@ void Hy3Layout::changeFocus(const PHLWORKSPACE& workspace, FocusShift shift) { if (node->parent != nullptr) node = node->parent; while (node->parent != nullptr) { if (node->parent->data.as_group().layout == Hy3GroupLayout::Tabbed) { - node->focus(); + node->focus(false); return; } @@ -1050,7 +1065,7 @@ bottom: node = node->data.as_group().focused_child; } - node->focus(); + node->focus(false); return; } @@ -1202,7 +1217,7 @@ hastab: && focus->data.as_group().focused_child != nullptr) focus = focus->data.as_group().focused_child; - focus->focus(); + focus->focus(false); tab_node->recalcSizePosRecursive(); } @@ -1324,6 +1339,16 @@ fsupdate: this->recalculateMonitor(monitor->ID); } +void Hy3Layout::warpCursorToBox(const Vector2D& pos, const Vector2D& size) { + auto cursorpos = Vector2D(g_pCompositor->m_sWLRCursor->x, g_pCompositor->m_sWLRCursor->y); + + if (cursorpos.x < pos.x || cursorpos.x >= pos.x + size.x || cursorpos.y < pos.y + || cursorpos.y >= pos.y + size.y) + { + g_pCompositor->warpCursorTo(pos + size / 2, true); + } +} + bool Hy3Layout::shouldRenderSelected(const PHLWINDOW& window) { if (window == nullptr) return false; auto* root = this->getWorkspaceRootGroup(window->m_pWorkspace); @@ -1791,7 +1816,7 @@ Hy3Node* Hy3Layout::shiftOrGetFocus( } node.updateTabBarRecursive(); - node.focus(); + node.focus(false); if (target_parent != target_group && target_parent != nullptr) target_parent->recalcSizePosRecursive(); diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index 7916261..d6b118b 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -112,7 +112,7 @@ public: void changeGroupEphemeralityOn(Hy3Node&, bool ephemeral); void shiftNode(Hy3Node&, ShiftDirection, bool once, bool visible); void shiftWindow(const PHLWORKSPACE& workspace, ShiftDirection, bool once, bool visible); - void shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection, bool visible); + void shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection, bool visible, bool warp); void moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsname, bool follow); void changeFocus(const PHLWORKSPACE& workspace, FocusShift); void focusTab( @@ -125,6 +125,7 @@ public: void setNodeSwallow(const PHLWORKSPACE& workspace, SetSwallowOption); void killFocusedNode(const PHLWORKSPACE& workspace); void expand(const PHLWORKSPACE& workspace, ExpandOption, ExpandFullscreenOption); + static void warpCursorToBox(const Vector2D& pos, const Vector2D& size); bool shouldRenderSelected(const PHLWINDOW&); diff --git a/src/Hy3Node.cpp b/src/Hy3Node.cpp index 04ef6f5..5a9dd3d 100644 --- a/src/Hy3Node.cpp +++ b/src/Hy3Node.cpp @@ -8,6 +8,7 @@ #include #include +#include "Hy3Layout.hpp" #include "Hy3Node.hpp" #include "globals.hpp" @@ -163,19 +164,25 @@ PHLWINDOW Hy3NodeData::as_window() { bool Hy3Node::operator==(const Hy3Node& rhs) const { return this->data == rhs.data; } -void Hy3Node::focus() { +void Hy3Node::focus(bool warp) { this->markFocused(); switch (this->data.type()) { - case Hy3NodeType::Window: - this->data.as_window()->setHidden(false); - g_pCompositor->focusWindow(this->data.as_window()); + case Hy3NodeType::Window: { + auto window = this->data.as_window(); + window->setHidden(false); + g_pCompositor->focusWindow(window); + if (warp) Hy3Layout::warpCursorToBox(window->m_vPosition, window->m_vSize); break; - case Hy3NodeType::Group: + } + case Hy3NodeType::Group: { g_pCompositor->focusWindow(nullptr); this->raiseToTop(); + + if (warp) Hy3Layout::warpCursorToBox(this->position, this->size); break; } + } } PHLWINDOW Hy3Node::bringToTop() { diff --git a/src/Hy3Node.hpp b/src/Hy3Node.hpp index 7a52f3c..2d3969e 100644 --- a/src/Hy3Node.hpp +++ b/src/Hy3Node.hpp @@ -95,7 +95,7 @@ struct Hy3Node { bool operator==(const Hy3Node&) const; - void focus(); + void focus(bool warp); void focusWindow(); PHLWINDOW bringToTop(); void markFocused(); diff --git a/src/dispatchers.cpp b/src/dispatchers.cpp index 843b17a..aae34e8 100644 --- a/src/dispatchers.cpp +++ b/src/dispatchers.cpp @@ -113,9 +113,20 @@ void dispatch_movefocus(std::string value) { auto args = CVarList(value); - if (auto shift = parseShiftArg(args[0])) { - g_Hy3Layout->shiftFocus(workspace, shift.value(), args[1] == "visible"); - } + static const auto no_cursor_warps = ConfigValue("general:no_cursor_warps"); + auto warp_cursor = !*no_cursor_warps; + + int argi = 0; + auto shift = parseShiftArg(args[argi++]); + if (!shift) return; + + auto visible = args[argi] == "visible"; + if (visible) argi++; + + if (args[argi] == "nowarp") warp_cursor = false; + else if (args[argi] == "warp") warp_cursor = true; + + g_Hy3Layout->shiftFocus(workspace, shift.value(), visible, warp_cursor); } void dispatch_move_to_workspace(std::string value) { From 584a1b1e357412a1a4ac40dbc6c4e5adaa7ec59b Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 5 May 2024 18:02:31 -0700 Subject: [PATCH 16/45] feat: add `hy3:warpcursor` --- CHANGELOG.md | 1 + README.md | 1 + src/Hy3Layout.cpp | 16 ++++++++++++++++ src/Hy3Layout.hpp | 1 + src/dispatchers.cpp | 5 +++++ 5 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 655cedf..4387074 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Upcoming +- Added `hy3:warpcursor` dispatcher to warp cursor to current node. - Added cursor warping options for `hy3:movefocus`. ## hl0.37.1 and before diff --git a/README.md b/README.md index 4b73234..2fc3f3b 100644 --- a/README.md +++ b/README.md @@ -321,6 +321,7 @@ plugin { - `visible` - only move between visible nodes, not hidden tabs - `warp` - warp the mouse to the selected window, even if `general:no_cursor_warps` is true. - `nowarp` - does not warp the mouse to the selected window, even if `general:no_cursor_warps` is false. + - `hy3:warpcursor` - warp the cursor to the center of the focused node - `hy3:movewindow, , [once], [visible]` - move a window left, up, down, or right - `once` - only move directly to the neighboring group, without moving into any of its subgroups - `visible` - only move between visible nodes, not hidden tabs diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index bc5dc5d..fc17e5d 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -925,6 +925,22 @@ void Hy3Layout::shiftFocus( } } +void Hy3Layout::warpCursor() { + auto current_window = g_pCompositor->m_pLastWindow.lock(); + + if (current_window != nullptr) { + if (current_window != nullptr) { + g_pCompositor->warpCursorTo(current_window->middle(), true); + } + } else { + auto* node = this->getWorkspaceFocusedNode(g_pCompositor->m_pLastMonitor->activeWorkspace); + + if (node != nullptr) { + g_pCompositor->warpCursorTo(node->position + node->size / 2); + } + } +} + void changeNodeWorkspaceRecursive(Hy3Node& node, const PHLWORKSPACE& workspace) { node.workspace = workspace; diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index d6b118b..e73938a 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -113,6 +113,7 @@ public: void shiftNode(Hy3Node&, ShiftDirection, bool once, bool visible); void shiftWindow(const PHLWORKSPACE& workspace, ShiftDirection, bool once, bool visible); void shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection, bool visible, bool warp); + void warpCursor(); void moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsname, bool follow); void changeFocus(const PHLWORKSPACE& workspace, FocusShift); void focusTab( diff --git a/src/dispatchers.cpp b/src/dispatchers.cpp index aae34e8..8ea2693 100644 --- a/src/dispatchers.cpp +++ b/src/dispatchers.cpp @@ -129,6 +129,10 @@ void dispatch_movefocus(std::string value) { g_Hy3Layout->shiftFocus(workspace, shift.value(), visible, warp_cursor); } +void dispatch_warpcursor(std::string value) { + g_Hy3Layout->warpCursor(); +} + void dispatch_move_to_workspace(std::string value) { auto origin_workspace = workspace_for_action(true); if (!valid(origin_workspace)) return; @@ -259,6 +263,7 @@ void registerDispatchers() { HyprlandAPI::addDispatcher(PHANDLE, "hy3:changegroup", dispatch_changegroup); HyprlandAPI::addDispatcher(PHANDLE, "hy3:setephemeral", dispatch_setephemeral); HyprlandAPI::addDispatcher(PHANDLE, "hy3:movefocus", dispatch_movefocus); + HyprlandAPI::addDispatcher(PHANDLE, "hy3:warpcursor", dispatch_warpcursor); HyprlandAPI::addDispatcher(PHANDLE, "hy3:movewindow", dispatch_movewindow); HyprlandAPI::addDispatcher(PHANDLE, "hy3:movetoworkspace", dispatch_move_to_workspace); HyprlandAPI::addDispatcher(PHANDLE, "hy3:changefocus", dispatch_changefocus); From ca420ab45df8d5579c1306c3845f12f0d9738ac1 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 5 May 2024 18:14:15 -0700 Subject: [PATCH 17/45] version: update to hyprland 0.40.0 --- CHANGELOG.md | 2 +- flake.lock | 47 +++++++++++++++++++++++++++++++++-------------- flake.nix | 2 +- hyprpm.toml | 3 ++- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4387074..52aa26a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Upcoming +## hl0.40.0 and before - Added `hy3:warpcursor` dispatcher to warp cursor to current node. - Added cursor warping options for `hy3:movefocus`. diff --git a/flake.lock b/flake.lock index 4364474..aac9871 100644 --- a/flake.lock +++ b/flake.lock @@ -32,38 +32,37 @@ "hyprland": { "inputs": { "hyprcursor": "hyprcursor", + "hyprland-protocols": "hyprland-protocols", "hyprlang": "hyprlang", "hyprwayland-scanner": "hyprwayland-scanner", "nixpkgs": "nixpkgs", "systems": "systems", + "wlroots": "wlroots", "xdph": "xdph" }, "locked": { - "lastModified": 1714933694, - "narHash": "sha256-gziEBZF1wmBBw3v0Ang3nN3QwoQWtFmBIORODJt38TE=", - "ref": "refs/heads/main", - "rev": "cddeec47a1fc0e70d8598fd10c29cd0e9489999f", - "revCount": 4617, - "submodules": true, - "type": "git", - "url": "https://github.com/hyprwm/Hyprland" + "lastModified": 1714837352, + "narHash": "sha256-QzzJTb+0CBqgAT0wKZsOt1rky5+u2zMUlNxbZcGj2VM=", + "owner": "hyprwm", + "repo": "Hyprland", + "rev": "cba1ade848feac44b2eda677503900639581c3f4", + "type": "github" }, "original": { - "submodules": true, - "type": "git", - "url": "https://github.com/hyprwm/Hyprland" + "owner": "hyprwm", + "repo": "Hyprland", + "rev": "cba1ade848feac44b2eda677503900639581c3f4", + "type": "github" } }, "hyprland-protocols": { "inputs": { "nixpkgs": [ "hyprland", - "xdph", "nixpkgs" ], "systems": [ "hyprland", - "xdph", "systems" ] }, @@ -167,9 +166,29 @@ "type": "github" } }, + "wlroots": { + "flake": false, + "locked": { + "lastModified": 1713731601, + "narHash": "sha256-bdcKdtLkusvv85DNuJsajZLFeq7bXp+x5AGP1Sd4wD8=", + "owner": "hyprwm", + "repo": "wlroots-hyprland", + "rev": "5c1d51c5a2793480f5b6c4341ad0797052aec2ea", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "wlroots-hyprland", + "rev": "5c1d51c5a2793480f5b6c4341ad0797052aec2ea", + "type": "github" + } + }, "xdph": { "inputs": { - "hyprland-protocols": "hyprland-protocols", + "hyprland-protocols": [ + "hyprland", + "hyprland-protocols" + ], "hyprlang": [ "hyprland", "hyprlang" diff --git a/flake.nix b/flake.nix index bf2c928..320f3f9 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1"; + hyprland.url = "github:hyprwm/Hyprland?rev=cba1ade848feac44b2eda677503900639581c3f4"; }; outputs = { self, hyprland, ... }: let diff --git a/hyprpm.toml b/hyprpm.toml index 339e1ef..8f1b732 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -9,7 +9,8 @@ commit_pins = [ ["3875679755014997776e091ff8903acfb311dd2f", "6f9719291386d5e3baad211420d60e54e9967ee6"], ["360ede79d124ffdeebbe8401f1ac4bc0dbec2c91", "6f9719291386d5e3baad211420d60e54e9967ee6"], ["e93fbd7c4f991cb8ef03e433ccc4d43587923e15", "6f9719291386d5e3baad211420d60e54e9967ee6"], - ["fe7b748eb668136dd0558b7c8279bfcd7ab4d759", "6f9719291386d5e3baad211420d60e54e9967ee6"] + ["fe7b748eb668136dd0558b7c8279bfcd7ab4d759", "6f9719291386d5e3baad211420d60e54e9967ee6"], + ["cba1ade848feac44b2eda677503900639581c3f4", "584a1b1e357412a1a4ac40dbc6c4e5adaa7ec59b"], # 0.40.0 ] [hy3] From 33c8d761ff1c1d2264f7549a7bcfc010929d153c Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 8 May 2024 15:27:45 -0700 Subject: [PATCH 18/45] fix: incorrect usage of as_group without check in focus_tab Closes #106 --- src/Hy3Layout.cpp | 4 +++- src/dispatchers.cpp | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index fc17e5d..64da39f 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -1178,7 +1178,9 @@ void Hy3Layout::focusTab( tab_node = this->getWorkspaceFocusedNode(workspace); if (tab_node == nullptr) return; - while (tab_node != nullptr && tab_node->data.as_group().layout != Hy3GroupLayout::Tabbed + while (tab_node != nullptr + && (tab_node->data.is_window() + || tab_node->data.as_group().layout != Hy3GroupLayout::Tabbed) && tab_node->parent != nullptr) tab_node = tab_node->parent; diff --git a/src/dispatchers.cpp b/src/dispatchers.cpp index 8ea2693..b13a6e0 100644 --- a/src/dispatchers.cpp +++ b/src/dispatchers.cpp @@ -129,9 +129,7 @@ void dispatch_movefocus(std::string value) { g_Hy3Layout->shiftFocus(workspace, shift.value(), visible, warp_cursor); } -void dispatch_warpcursor(std::string value) { - g_Hy3Layout->warpCursor(); -} +void dispatch_warpcursor(std::string value) { g_Hy3Layout->warpCursor(); } void dispatch_move_to_workspace(std::string value) { auto origin_workspace = workspace_for_action(true); From 400930e0391a0e13ebbc6a3b9fe162e00aaad89a Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 19 May 2024 01:48:12 -0700 Subject: [PATCH 19/45] fixup: fix breakage after cursor rewrite --- flake.lock | 77 +++++++++++++++++---------------------------- flake.nix | 4 ++- src/Hy3Layout.cpp | 3 +- src/dispatchers.cpp | 2 +- 4 files changed, 35 insertions(+), 51 deletions(-) diff --git a/flake.lock b/flake.lock index aac9871..f670c03 100644 --- a/flake.lock +++ b/flake.lock @@ -32,46 +32,47 @@ "hyprland": { "inputs": { "hyprcursor": "hyprcursor", - "hyprland-protocols": "hyprland-protocols", "hyprlang": "hyprlang", "hyprwayland-scanner": "hyprwayland-scanner", "nixpkgs": "nixpkgs", "systems": "systems", - "wlroots": "wlroots", "xdph": "xdph" }, "locked": { - "lastModified": 1714837352, - "narHash": "sha256-QzzJTb+0CBqgAT0wKZsOt1rky5+u2zMUlNxbZcGj2VM=", - "owner": "hyprwm", - "repo": "Hyprland", - "rev": "cba1ade848feac44b2eda677503900639581c3f4", - "type": "github" + "lastModified": 1715817355, + "narHash": "sha256-/XuIc6AkzUZVJkKNYBCSGK+G5sLgfLY9zd+gIXLNcGA=", + "ref": "refs/heads/main", + "rev": "de9798fcf9494eb082bd168175390c0d47b8478b", + "revCount": 4702, + "submodules": true, + "type": "git", + "url": "https://github.com/hyprwm/hyprland" }, "original": { - "owner": "hyprwm", - "repo": "Hyprland", - "rev": "cba1ade848feac44b2eda677503900639581c3f4", - "type": "github" + "submodules": true, + "type": "git", + "url": "https://github.com/hyprwm/hyprland" } }, "hyprland-protocols": { "inputs": { "nixpkgs": [ "hyprland", + "xdph", "nixpkgs" ], "systems": [ "hyprland", + "xdph", "systems" ] }, "locked": { - "lastModified": 1714869498, - "narHash": "sha256-vbLVOWvQqo4n1yvkg/Q70VTlPbMmTiCQfNTgcWDCfJM=", + "lastModified": 1691753796, + "narHash": "sha256-zOEwiWoXk3j3+EoF3ySUJmberFewWlagvewDRuWYAso=", "owner": "hyprwm", "repo": "hyprland-protocols", - "rev": "e06482e0e611130cd1929f75e8c1cf679e57d161", + "rev": "0c2ce70625cb30aef199cb388f99e19a61a6ce03", "type": "github" }, "original": { @@ -92,11 +93,11 @@ ] }, "locked": { - "lastModified": 1713121246, - "narHash": "sha256-502X0Q0fhN6tJK7iEUA8CghONKSatW/Mqj4Wappd++0=", + "lastModified": 1715610285, + "narHash": "sha256-i8ZQeEiwXYhmzqyUaFeHhnRVu6L7g5cy33PcTQjPw4U=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "78fcaa27ae9e1d782faa3ff06c8ea55ddce63706", + "rev": "19ec261528f924a275860dcab7979519e41809e5", "type": "github" }, "original": { @@ -117,11 +118,11 @@ ] }, "locked": { - "lastModified": 1714755542, - "narHash": "sha256-D0pg+ZRwrt4lavZ97Ca8clsgbPA3duLj8iEM7riaIFY=", + "lastModified": 1715608589, + "narHash": "sha256-vimNaLjLcoNIvBhF37GaB6PRYEvKMamY3UnDE9M5MW8=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "1270ebaa539e56d61b708c24b072b09cbbd3a828", + "rev": "65c2636484e5cb00583b8a7446c3fb657f568883", "type": "github" }, "original": { @@ -132,11 +133,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1714253743, - "narHash": "sha256-mdTQw2XlariysyScCv2tTE45QSU9v/ezLcHJ22f0Nxc=", + "lastModified": 1715447595, + "narHash": "sha256-VsVAUQOj/cS1LCOmMjAGeRksXIAdPnFIjCQ0XLkCsT0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "58a1abdbae3217ca6b702f03d3b35125d88a2994", + "rev": "062ca2a9370a27a35c524dc82d540e6e9824b652", "type": "github" }, "original": { @@ -166,29 +167,9 @@ "type": "github" } }, - "wlroots": { - "flake": false, - "locked": { - "lastModified": 1713731601, - "narHash": "sha256-bdcKdtLkusvv85DNuJsajZLFeq7bXp+x5AGP1Sd4wD8=", - "owner": "hyprwm", - "repo": "wlroots-hyprland", - "rev": "5c1d51c5a2793480f5b6c4341ad0797052aec2ea", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "wlroots-hyprland", - "rev": "5c1d51c5a2793480f5b6c4341ad0797052aec2ea", - "type": "github" - } - }, "xdph": { "inputs": { - "hyprland-protocols": [ - "hyprland", - "hyprland-protocols" - ], + "hyprland-protocols": "hyprland-protocols", "hyprlang": [ "hyprland", "hyprlang" @@ -203,11 +184,11 @@ ] }, "locked": { - "lastModified": 1714060055, - "narHash": "sha256-j43TS9wv9luaAlpxcxw0sjxkbcc2mGANVR2RYgo3RCw=", + "lastModified": 1714662532, + "narHash": "sha256-Pj2xGSYhapYbXL7sk7TTlOtCZcTfPQoL3fPbZeg7L4Y=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "0fe840441e43da12cd7865ed9aa8cdc35a8da85a", + "rev": "1f228ba2f1f254195c0b571302b37482861abee3", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 320f3f9..c0b626a 100644 --- a/flake.nix +++ b/flake.nix @@ -30,7 +30,9 @@ impure = import ./shell.nix { pkgs = import {}; hlversion = props.version; - hyprland = (pkgs.appendOverlays [ hyprland.overlays.hyprland-packages ]).hyprland-debug; + hyprland = (pkgs.appendOverlays [ hyprland.overlays.hyprland-packages ]).hyprland-debug.overrideAttrs { + dontStrip = true; + }; }; }); }; diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 64da39f..12963f8 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "Hy3Layout.hpp" @@ -1358,7 +1359,7 @@ fsupdate: } void Hy3Layout::warpCursorToBox(const Vector2D& pos, const Vector2D& size) { - auto cursorpos = Vector2D(g_pCompositor->m_sWLRCursor->x, g_pCompositor->m_sWLRCursor->y); + auto cursorpos = g_pPointerManager->position(); if (cursorpos.x < pos.x || cursorpos.x >= pos.x + size.x || cursorpos.y < pos.y || cursorpos.y >= pos.y + size.y) diff --git a/src/dispatchers.cpp b/src/dispatchers.cpp index b13a6e0..6a861d5 100644 --- a/src/dispatchers.cpp +++ b/src/dispatchers.cpp @@ -113,7 +113,7 @@ void dispatch_movefocus(std::string value) { auto args = CVarList(value); - static const auto no_cursor_warps = ConfigValue("general:no_cursor_warps"); + static const auto no_cursor_warps = ConfigValue("cursor:no_warps"); auto warp_cursor = !*no_cursor_warps; int argi = 0; From de58d24c294b4dfad4d10492b67ac39c2c0944cb Mon Sep 17 00:00:00 2001 From: tuxx Date: Sun, 19 May 2024 23:37:49 +0200 Subject: [PATCH 20/45] Update README.md Added hyprpm update -f to readme according to bug in #109 --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 2fc3f3b..875675d 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,12 @@ To update hy3 (and all other plugins), run hyprpm update ``` +Sometimes the headers from hyprland are not updated, if this happens run (See #109 for an example of where this happened) + +```sh +hyprpm update -f +``` + (See [the wiki](https://wiki.hyprland.org/Plugins/Using-Plugins/) for details.) > [!WARNING] From c9405564c880a0e6cef0e6413fb175812c85fa8e Mon Sep 17 00:00:00 2001 From: tuxx Date: Sun, 19 May 2024 23:39:08 +0200 Subject: [PATCH 21/45] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 875675d..0f86850 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ To update hy3 (and all other plugins), run hyprpm update ``` -Sometimes the headers from hyprland are not updated, if this happens run (See #109 for an example of where this happened) +Sometimes the headers from hyprland are not updated, if this happens run (See [issue #109](https://github.com/outfoxxed/hy3/issues/109) for an example of where this happened) ```sh hyprpm update -f From 3025a015ea21a1fda84a5a5c847ca31e699fd237 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 24 May 2024 04:34:24 -0700 Subject: [PATCH 22/45] fixup: fix compile --- flake.lock | 42 +++++++++++++++++++++--------------------- flake.nix | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/flake.lock b/flake.lock index f670c03..e7610a4 100644 --- a/flake.lock +++ b/flake.lock @@ -16,11 +16,11 @@ ] }, "locked": { - "lastModified": 1713612213, - "narHash": "sha256-zJboXgWNpNhKyNF8H/3UYzWkx7w00TOCGKi3cwi+tsw=", + "lastModified": 1716327911, + "narHash": "sha256-PI+wygItS/TKzi4gEAROvKTUzTx9GT+PGBttS/IOA/Q=", "owner": "hyprwm", "repo": "hyprcursor", - "rev": "cab4746180f210a3c1dd3d53e45c510e309e90e1", + "rev": "27ca640abeef2d425b5dbecf804f5eb622cef56d", "type": "github" }, "original": { @@ -39,19 +39,19 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1715817355, - "narHash": "sha256-/XuIc6AkzUZVJkKNYBCSGK+G5sLgfLY9zd+gIXLNcGA=", + "lastModified": 1716491954, + "narHash": "sha256-Qf1mEPacXhhM5KFm7HG2F/UBfzkjSBK57gKquA5TAVY=", "ref": "refs/heads/main", - "rev": "de9798fcf9494eb082bd168175390c0d47b8478b", - "revCount": 4702, + "rev": "4e42107d25dc47ee94da282db233f85f1e4c6bd0", + "revCount": 4733, "submodules": true, "type": "git", - "url": "https://github.com/hyprwm/hyprland" + "url": "https://github.com/hyprwm/Hyprland" }, "original": { "submodules": true, "type": "git", - "url": "https://github.com/hyprwm/hyprland" + "url": "https://github.com/hyprwm/Hyprland" } }, "hyprland-protocols": { @@ -93,11 +93,11 @@ ] }, "locked": { - "lastModified": 1715610285, - "narHash": "sha256-i8ZQeEiwXYhmzqyUaFeHhnRVu6L7g5cy33PcTQjPw4U=", + "lastModified": 1715791527, + "narHash": "sha256-HhQ4zvGHrRjR63ltySSeg+x+0jb0lepiutWdnFhLRoo=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "19ec261528f924a275860dcab7979519e41809e5", + "rev": "969cb076e5b76f2e823aeca1937a3e1f159812ee", "type": "github" }, "original": { @@ -118,11 +118,11 @@ ] }, "locked": { - "lastModified": 1715608589, - "narHash": "sha256-vimNaLjLcoNIvBhF37GaB6PRYEvKMamY3UnDE9M5MW8=", + "lastModified": 1716058375, + "narHash": "sha256-CwjWoVnBZE5SBpRx9dgSQGCr4Goxyfcyv3zZbOhVqzk=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "65c2636484e5cb00583b8a7446c3fb657f568883", + "rev": "3afed4364790aebe0426077631af1e164a9650cc", "type": "github" }, "original": { @@ -133,11 +133,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1715447595, - "narHash": "sha256-VsVAUQOj/cS1LCOmMjAGeRksXIAdPnFIjCQ0XLkCsT0=", + "lastModified": 1716330097, + "narHash": "sha256-8BO3B7e3BiyIDsaKA0tY8O88rClYRTjvAp66y+VBUeU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "062ca2a9370a27a35c524dc82d540e6e9824b652", + "rev": "5710852ba686cc1fd0d3b8e22b3117d43ba374c2", "type": "github" }, "original": { @@ -184,11 +184,11 @@ ] }, "locked": { - "lastModified": 1714662532, - "narHash": "sha256-Pj2xGSYhapYbXL7sk7TTlOtCZcTfPQoL3fPbZeg7L4Y=", + "lastModified": 1716290197, + "narHash": "sha256-1u9Exrc7yx9qtES2brDh7/DDZ8w8ap1nboIOAtCgeuM=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "1f228ba2f1f254195c0b571302b37482861abee3", + "rev": "91e48d6acd8a5a611d26f925e51559ab743bc438", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c0b626a..5fd1e1b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "github:hyprwm/Hyprland?rev=cba1ade848feac44b2eda677503900639581c3f4"; + hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1"; }; outputs = { self, hyprland, ... }: let From 445381f87177b90404d597e617915c8bad3c02b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 1 Jun 2024 20:02:48 +0200 Subject: [PATCH 23/45] Damage tab bar each tick to avoid defects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This solution is hacky and needs to be improved Signed-off-by: Šimon Brandner --- src/TabGroup.cpp | 8 ++++++++ src/TabGroup.hpp | 1 + 2 files changed, 9 insertions(+) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 86eb679..5da614f 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -271,6 +271,14 @@ void Hy3TabBar::tick() { } if (this->entries.empty()) this->destroy = true; + + damage(); +} + +void Hy3TabBar::damage() { + auto pos = this->entries.front().node.position; + auto box = CBox {pos.x, pos.y, this->size.x, this->size.y}; + g_pHyprRenderer->damageBox(&box); } void Hy3TabBar::updateNodeList(std::list& nodes) { diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 12117f3..5640958 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -67,6 +67,7 @@ public: Hy3TabBar(); void beginDestroy(); + void damage(); void tick(); void updateNodeList(std::list& nodes); void updateAnimations(bool warp = false); From 968cadf663a6d5fb514bda8b645e1eb9fbf60e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 4 Jun 2024 09:24:42 +0200 Subject: [PATCH 24/45] Damage bar when animating workspace slide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/TabGroup.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 5da614f..30ce8a8 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -271,8 +271,6 @@ void Hy3TabBar::tick() { } if (this->entries.empty()) this->destroy = true; - - damage(); } void Hy3TabBar::damage() { @@ -463,6 +461,10 @@ void Hy3TabGroup::tick() { } else { if (this->bar.fade_opacity.goal() != 1.0) this->bar.fade_opacity = 1.0; } + + if (this->workspace->m_vRenderOffset.isBeingAnimated()) { + this->bar.damage(); + } } auto pos = this->pos.value(); From 2728dbed6a2a038fc542ef5837af4a185146ce4d Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 7 Jun 2024 13:16:59 -0700 Subject: [PATCH 25/45] fix: emit fullscreen event and update window rules+decos on fullscreen --- CHANGELOG.md | 3 +++ src/Hy3Layout.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52aa26a..31c6a96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +# Upcoming +- Fixed IPC and wlr-foreign-toplevel not getting fullscreen and maximize events. + ## hl0.40.0 and before - Added `hy3:warpcursor` dispatcher to warp cursor to current node. diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 12963f8..dad8404 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -503,6 +503,12 @@ void Hy3Layout::fullscreenRequestForWindow( window->m_bIsFullscreen = on; window->m_pWorkspace->m_bHasFullscreenWindow = !window->m_pWorkspace->m_bHasFullscreenWindow; + window->updateDynamicRules(); + window->updateWindowDecos(); + + g_pEventManager->postEvent(SHyprIPCEvent {"fullscreen", std::to_string((int) on)}); + EMIT_HOOK_EVENT("fullscreen", window); + if (!window->m_bIsFullscreen) { auto* node = this->getNodeFromWindow(window); From cf919397d4a80f2ae5e2c56e33979fc91d7fd78b Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 7 Jun 2024 14:10:23 -0700 Subject: [PATCH 26/45] fix: moveNodeToWorkspace breakage across monitors (hy3 dispatchers) --- CHANGELOG.md | 1 + src/Hy3Layout.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c6a96..aa889e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ # Upcoming - Fixed IPC and wlr-foreign-toplevel not getting fullscreen and maximize events. +- Fixed glitches when moving nodes between monitors with hy3 dispatchers. ## hl0.40.0 and before diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index dad8404..0bf5115 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -953,9 +953,12 @@ void changeNodeWorkspaceRecursive(Hy3Node& node, const PHLWORKSPACE& workspace) if (node.data.is_window()) { auto window = node.data.as_window(); + g_pHyprRenderer->damageWindow(window); window->moveToWorkspace(workspace); + window->m_iMonitorID = workspace->m_iMonitorID; window->updateToplevel(); window->updateDynamicRules(); + window->uncacheWindowDecos(); } else { for (auto* child: node.data.as_group().children) { changeNodeWorkspaceRecursive(*child, workspace); @@ -996,6 +999,7 @@ void Hy3Layout::moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsna if (focused_window != nullptr && (focused_window_node == nullptr || focused_window->m_bIsFullscreen)) { + g_pHyprRenderer->damageWindow(focused_window); g_pCompositor->moveWindowToWorkspaceSafe(focused_window, workspace); } else { if (node == nullptr) return; @@ -1015,6 +1019,8 @@ void Hy3Layout::moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsna changeNodeWorkspaceRecursive(*node, workspace); this->insertNode(*node); + g_pCompositor->updateWorkspaceWindows(origin->m_iID); + g_pCompositor->updateWorkspaceWindows(workspace->m_iID); } if (follow) { From 11fcce578038798da2aa39ca5dfb33fca0f4a22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 9 Jun 2024 17:01:32 +0200 Subject: [PATCH 27/45] Damage the whole node when animating slide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/TabGroup.cpp | 18 +++++++++++------- src/TabGroup.hpp | 4 +++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 30ce8a8..4c4a9d5 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -273,12 +273,6 @@ void Hy3TabBar::tick() { if (this->entries.empty()) this->destroy = true; } -void Hy3TabBar::damage() { - auto pos = this->entries.front().node.position; - auto box = CBox {pos.x, pos.y, this->size.x, this->size.y}; - g_pHyprRenderer->damageBox(&box); -} - void Hy3TabBar::updateNodeList(std::list& nodes) { std::list::iterator> removed_entries; @@ -415,7 +409,17 @@ Hy3TabGroup::Hy3TabGroup(Hy3Node& node) { this->size.warp(); } +void Hy3TabGroup::damage() { + auto pos = this->node->position; + auto size = this->node->size; + auto box = CBox {pos.x, pos.y, size.x, size.y}; + + g_pHyprRenderer->damageBox(&box); +} + void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { + this->node = &node; + static const auto gaps_in = ConfigValue("general:gaps_in"); static const auto gaps_out = ConfigValue("general:gaps_out"); static const auto bar_height = ConfigValue("plugin:hy3:tabs:height"); @@ -463,7 +467,7 @@ void Hy3TabGroup::tick() { } if (this->workspace->m_vRenderOffset.isBeingAnimated()) { - this->bar.damage(); + this->damage(); } } diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 5640958..910b304 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -67,7 +67,6 @@ public: Hy3TabBar(); void beginDestroy(); - void damage(); void tick(); void updateNodeList(std::list& nodes); void updateAnimations(bool warp = false); @@ -106,6 +105,7 @@ private: std::vector stencil_windows; Vector2D last_pos; Vector2D last_size; + Hy3Node* node; Hy3TabGroup(); @@ -114,4 +114,6 @@ private: // UB if node is not a group. void updateStencilWindows(Hy3Node&); + + void damage(); }; From 144176a37a2d098bcda857653043d2685a1a0f9a Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 9 Jun 2024 18:11:42 -0700 Subject: [PATCH 28/45] fixup: fix compile against 1423707 Fixes #177 --- flake.lock | 32 ++++++++++++++++---------------- src/TabGroup.cpp | 8 ++++---- src/TabGroup.hpp | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/flake.lock b/flake.lock index e7610a4..72bae96 100644 --- a/flake.lock +++ b/flake.lock @@ -16,11 +16,11 @@ ] }, "locked": { - "lastModified": 1716327911, - "narHash": "sha256-PI+wygItS/TKzi4gEAROvKTUzTx9GT+PGBttS/IOA/Q=", + "lastModified": 1717181720, + "narHash": "sha256-yv+QZWsusu/NWjydkxixHC2g+tIJ9v+xkE2EiVpJj6g=", "owner": "hyprwm", "repo": "hyprcursor", - "rev": "27ca640abeef2d425b5dbecf804f5eb622cef56d", + "rev": "9e27a2c2ceb1e0b85bd55b0afefad196056fe87c", "type": "github" }, "original": { @@ -39,11 +39,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1716491954, - "narHash": "sha256-Qf1mEPacXhhM5KFm7HG2F/UBfzkjSBK57gKquA5TAVY=", + "lastModified": 1717970802, + "narHash": "sha256-kFnaAmte/N1mrbHEQyrwDu9+laZzVAi4N2nQodCNfgg=", "ref": "refs/heads/main", - "rev": "4e42107d25dc47ee94da282db233f85f1e4c6bd0", - "revCount": 4733, + "rev": "1423707dbefc0329e80895451903a77ab684f7ea", + "revCount": 4789, "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" @@ -93,11 +93,11 @@ ] }, "locked": { - "lastModified": 1715791527, - "narHash": "sha256-HhQ4zvGHrRjR63ltySSeg+x+0jb0lepiutWdnFhLRoo=", + "lastModified": 1716473782, + "narHash": "sha256-+qLn4lsHU6iL3+HTo1gTQ1tWzet8K9h+IfVemzEQZj8=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "969cb076e5b76f2e823aeca1937a3e1f159812ee", + "rev": "87d5d984109c839482b88b4795db073eb9ed446f", "type": "github" }, "original": { @@ -118,11 +118,11 @@ ] }, "locked": { - "lastModified": 1716058375, - "narHash": "sha256-CwjWoVnBZE5SBpRx9dgSQGCr4Goxyfcyv3zZbOhVqzk=", + "lastModified": 1717784906, + "narHash": "sha256-YxmfxHfWed1fosaa7fC1u7XoKp1anEZU+7Lh/ojRKoM=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "3afed4364790aebe0426077631af1e164a9650cc", + "rev": "0f30f9eca6e404130988554accbb64d1c9ec877d", "type": "github" }, "original": { @@ -133,11 +133,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1716330097, - "narHash": "sha256-8BO3B7e3BiyIDsaKA0tY8O88rClYRTjvAp66y+VBUeU=", + "lastModified": 1717602782, + "narHash": "sha256-pL9jeus5QpX5R+9rsp3hhZ+uplVHscNJh8n8VpqscM0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5710852ba686cc1fd0d3b8e22b3117d43ba374c2", + "rev": "e8057b67ebf307f01bdcc8fba94d94f75039d1f6", "type": "github" }, "original": { diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 86eb679..2d51f59 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -117,7 +117,7 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) { auto rounding = std::min((double) *s_rounding * scale, std::min(width * 0.5, height * 0.5)); - if (this->texture.m_iTexID == 0 + if (this->texture->m_iTexID == 0 // clang-format off || this->last_render.x != box.x || this->last_render.y != box.y @@ -228,9 +228,9 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) { cairo_surface_flush(cairo_surface); auto data = cairo_image_surface_get_data(cairo_surface); - this->texture.allocate(); + this->texture->allocate(); - glBindTexture(GL_TEXTURE_2D, this->texture.m_iTexID); + glBindTexture(GL_TEXTURE_2D, this->texture->m_iTexID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -244,7 +244,7 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) { cairo_destroy(cairo); cairo_surface_destroy(cairo_surface); } else { - glBindTexture(GL_TEXTURE_2D, this->texture.m_iTexID); + glBindTexture(GL_TEXTURE_2D, this->texture->m_iTexID); } } diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 12117f3..0fe1d95 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -15,7 +15,7 @@ class Hy3TabBar; struct Hy3TabBarEntry { std::string window_title; bool destroying = false; - CTexture texture; + SP texture; CAnimatedVariable focused; CAnimatedVariable urgent; CAnimatedVariable offset; // 0.0-1.0 of total bar From 3bf93f5457cbeb8a4e85d5c0c919f22c212aaeab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 10 Jun 2024 10:28:00 +0200 Subject: [PATCH 29/45] Fix visual defects when switching workspaces properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/TabGroup.cpp | 37 +++++++++++++++++++++++-------------- src/TabGroup.hpp | 3 +-- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 4c4a9d5..24b9e6a 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -409,14 +409,6 @@ Hy3TabGroup::Hy3TabGroup(Hy3Node& node) { this->size.warp(); } -void Hy3TabGroup::damage() { - auto pos = this->node->position; - auto size = this->node->size; - auto box = CBox {pos.x, pos.y, size.x, size.y}; - - g_pHyprRenderer->damageBox(&box); -} - void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { this->node = &node; @@ -453,6 +445,11 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { } } +void damageBox(const Vector2D* position, const Vector2D* size) { + auto box = CBox {position->x, position->y, size->x, size->y}; + g_pHyprRenderer->damageBox(&box); +} + void Hy3TabGroup::tick() { static const auto enter_from_top = ConfigValue("plugin:hy3:tabs:from_top"); static const auto padding = ConfigValue("plugin:hy3:tabs:padding"); @@ -466,8 +463,22 @@ void Hy3TabGroup::tick() { if (this->bar.fade_opacity.goal() != 1.0) this->bar.fade_opacity = 1.0; } - if (this->workspace->m_vRenderOffset.isBeingAnimated()) { - this->damage(); + auto workspaceOffset = this->workspace->m_vRenderOffset.value(); + if (this->last_workspace_offset != workspaceOffset) { + // First we damage the area where the bar was during the previous + // tick, cleaning up after ourselves + auto pos = this->last_pos + this->last_workspace_offset; + auto size = this->last_size; + damageBox(&pos, &size); + + // Then we damage the current position of the bar, to avoid seeing + // glitches with animations disabled + pos = this->pos.value() + workspaceOffset; + size = this->size.value(); + damageBox(&pos, &size); + + this->bar.damaged = true; + this->last_workspace_offset = workspaceOffset; } } @@ -475,8 +486,7 @@ void Hy3TabGroup::tick() { auto size = this->size.value(); if (this->last_pos != pos || this->last_size != size) { - CBox damage_box = {this->last_pos.x, this->last_pos.y, this->last_size.x, this->last_size.y}; - g_pHyprRenderer->damageBox(&damage_box); + damageBox(&this->last_pos, &this->last_size); this->bar.damaged = true; this->last_pos = pos; @@ -490,8 +500,7 @@ void Hy3TabGroup::tick() { pos.y -= *padding; } - CBox damage_box = {pos.x, pos.y, size.x, size.y}; - g_pHyprRenderer->damageBox(&damage_box); + damageBox(&pos, &size); this->bar.damaged = true; this->bar.dirty = false; diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 910b304..26eda2e 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -103,6 +103,7 @@ public: private: std::vector stencil_windows; + Vector2D last_workspace_offset; Vector2D last_pos; Vector2D last_size; Hy3Node* node; @@ -114,6 +115,4 @@ private: // UB if node is not a group. void updateStencilWindows(Hy3Node&); - - void damage(); }; From 0cb9391f2ba34251c4e1012544f0a16e346ec4a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 10 Jun 2024 10:29:58 +0200 Subject: [PATCH 30/45] Remove left-over code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/TabGroup.cpp | 2 -- src/TabGroup.hpp | 1 - 2 files changed, 3 deletions(-) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 24b9e6a..02caeff 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -410,8 +410,6 @@ Hy3TabGroup::Hy3TabGroup(Hy3Node& node) { } void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { - this->node = &node; - static const auto gaps_in = ConfigValue("general:gaps_in"); static const auto gaps_out = ConfigValue("general:gaps_out"); static const auto bar_height = ConfigValue("plugin:hy3:tabs:height"); diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 26eda2e..149340d 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -106,7 +106,6 @@ private: Vector2D last_workspace_offset; Vector2D last_pos; Vector2D last_size; - Hy3Node* node; Hy3TabGroup(); From 45c6d01fbee2a0849c6b805d53e535ef5ea18466 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 10 Jun 2024 02:48:47 -0700 Subject: [PATCH 31/45] fix: crash on creating tab bars --- src/TabGroup.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 2d51f59..caa9b2f 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -11,6 +11,8 @@ #include #include "globals.hpp" +#include "src/helpers/memory/SharedPtr.hpp" +#include "src/render/Texture.hpp" Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_bar), node(node) { this->focused @@ -52,6 +54,8 @@ Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_b this->vertical_pos = 0.0; this->fade_opacity = 1.0; + + this->texture = makeShared(); } bool Hy3TabBarEntry::operator==(const Hy3Node& node) const { return this->node == node; } From 5693ea255455c0c35d97353031de80def61f1e15 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 10 Jun 2024 18:57:45 -0700 Subject: [PATCH 32/45] version: update to hyprland 0.41.0 --- CHANGELOG.md | 4 +++- flake.lock | 9 +++++---- flake.nix | 2 +- hyprpm.toml | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa889e4..c1f5138 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ # Changelog -# Upcoming +# hl0.41.0 and before + - Fixed IPC and wlr-foreign-toplevel not getting fullscreen and maximize events. - Fixed glitches when moving nodes between monitors with hy3 dispatchers. +- Fixed glitchy tab bar effects when switching workspaces ## hl0.40.0 and before diff --git a/flake.lock b/flake.lock index 72bae96..fdf18d9 100644 --- a/flake.lock +++ b/flake.lock @@ -39,16 +39,17 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1717970802, - "narHash": "sha256-kFnaAmte/N1mrbHEQyrwDu9+laZzVAi4N2nQodCNfgg=", + "lastModified": 1718029386, + "narHash": "sha256-iX/l3UT8iXu8psu2UirFX11Yg2zYwpgzoXB32oM3N3U=", "ref": "refs/heads/main", - "rev": "1423707dbefc0329e80895451903a77ab684f7ea", - "revCount": 4789, + "rev": "ea2501d4556f84d3de86a4ae2f4b22a474555b9f", + "revCount": 4794, "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" }, "original": { + "rev": "ea2501d4556f84d3de86a4ae2f4b22a474555b9f", "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" diff --git a/flake.nix b/flake.nix index 5fd1e1b..6dd4a47 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1"; + hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=ea2501d4556f84d3de86a4ae2f4b22a474555b9f"; }; outputs = { self, hyprland, ... }: let diff --git a/hyprpm.toml b/hyprpm.toml index 8f1b732..73e4c64 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -11,6 +11,7 @@ commit_pins = [ ["e93fbd7c4f991cb8ef03e433ccc4d43587923e15", "6f9719291386d5e3baad211420d60e54e9967ee6"], ["fe7b748eb668136dd0558b7c8279bfcd7ab4d759", "6f9719291386d5e3baad211420d60e54e9967ee6"], ["cba1ade848feac44b2eda677503900639581c3f4", "584a1b1e357412a1a4ac40dbc6c4e5adaa7ec59b"], # 0.40.0 + ["ea2501d4556f84d3de86a4ae2f4b22a474555b9f", "b6a777d2714628d2cda8843aec73a700ef269899"], # 0.41.0 ] [hy3] From e090c684afe6bb5e789f7eff4bb0c382688fcbfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 11 Jun 2024 10:32:00 +0200 Subject: [PATCH 33/45] Fix tab bar fade visual defects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/TabGroup.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index f892a83..7627e68 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -482,6 +482,12 @@ void Hy3TabGroup::tick() { this->bar.damaged = true; this->last_workspace_offset = workspaceOffset; } + + if (this->workspace->m_fAlpha.isBeingAnimated()) { + auto pos = this->pos.value(); + auto size = this->size.value(); + damageBox(&pos, &size); + } } auto pos = this->pos.value(); From 4c02545bf31ffbcd2124f6827db2c6c135a5c9bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 12 Jun 2024 10:28:48 +0200 Subject: [PATCH 34/45] Include things from hyprutils MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/hyprwm/Hyprland/commit/8c64a4bad710fb18e9b84812bd680a89d1e93661 Signed-off-by: Šimon Brandner --- src/TabGroup.cpp | 2 +- src/dispatchers.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index f892a83..a462c09 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -7,11 +7,11 @@ #include #include #include +#include #include #include #include "globals.hpp" -#include "src/helpers/memory/SharedPtr.hpp" #include "src/render/Texture.hpp" Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_bar), node(node) { diff --git a/src/dispatchers.cpp b/src/dispatchers.cpp index 6a861d5..e4b59c3 100644 --- a/src/dispatchers.cpp +++ b/src/dispatchers.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "dispatchers.hpp" #include "globals.hpp" From 34db455a5ae73d880c1f0fd4c3568e524393a310 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 12 Jun 2024 13:06:12 -0700 Subject: [PATCH 35/45] changelog: tab bar fade fixes --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1f5138..24bba97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +# Upcoming + +- Fixed glitchy tab bar effects when switching workspaces with fade effect. + # hl0.41.0 and before - Fixed IPC and wlr-foreign-toplevel not getting fullscreen and maximize events. From 1fd12b26889c512d2ee24aa6532b79c74371b85a Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 12 Jun 2024 13:17:34 -0700 Subject: [PATCH 36/45] fixup: update lockfile for hyprutils changes --- flake.lock | 36 +++++++++++++++++++++++++++++++----- flake.nix | 2 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index fdf18d9..512b8f8 100644 --- a/flake.lock +++ b/flake.lock @@ -33,23 +33,24 @@ "inputs": { "hyprcursor": "hyprcursor", "hyprlang": "hyprlang", + "hyprutils": "hyprutils", "hyprwayland-scanner": "hyprwayland-scanner", "nixpkgs": "nixpkgs", "systems": "systems", "xdph": "xdph" }, "locked": { - "lastModified": 1718029386, - "narHash": "sha256-iX/l3UT8iXu8psu2UirFX11Yg2zYwpgzoXB32oM3N3U=", + "lastModified": 1718119065, + "narHash": "sha256-D/LR6g9JSHQBZhz5zBrQ6pyGiRr5nQx0JaJn1RlHFr4=", "ref": "refs/heads/main", - "rev": "ea2501d4556f84d3de86a4ae2f4b22a474555b9f", - "revCount": 4794, + "rev": "8c64a4bad710fb18e9b84812bd680a89d1e93661", + "revCount": 4800, "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" }, "original": { - "rev": "ea2501d4556f84d3de86a4ae2f4b22a474555b9f", + "rev": "8c64a4bad710fb18e9b84812bd680a89d1e93661", "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" @@ -107,6 +108,31 @@ "type": "github" } }, + "hyprutils": { + "inputs": { + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1717881334, + "narHash": "sha256-a0inRgJhPL6v9v7RPM/rx1kbXdfe3xJA1c9z0ZkYnh4=", + "owner": "hyprwm", + "repo": "hyprutils", + "rev": "0693f9398ab693d89c9a0aa3b3d062dd61b7a60e", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprutils", + "type": "github" + } + }, "hyprwayland-scanner": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 6dd4a47..035d90b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=ea2501d4556f84d3de86a4ae2f4b22a474555b9f"; + hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=8c64a4bad710fb18e9b84812bd680a89d1e93661"; }; outputs = { self, hyprland, ... }: let From 7b5f0e547d64383fbb9f31c3d6b97a6c102b32e9 Mon Sep 17 00:00:00 2001 From: i1i1 Date: Sun, 16 Jun 2024 21:32:07 +0300 Subject: [PATCH 37/45] Update README to use git fetcher instead of github fetcher --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0f86850..a0b9499 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,8 @@ Assuming you use hyprland's home manager module, you can easily integrate hy3 by inputs.nixpkgs.follows = "nixpkgs"; }; - hyprland.url = "github:hyprwm/Hyprland?ref=v{version}"; # where {version} is the hyprland release version + hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&ref={version}"; + # where {version} is the hyprland release version # or "github:hyprwm/Hyprland" to follow the development branch hy3 = { @@ -138,7 +139,7 @@ hyprpm update Sometimes the headers from hyprland are not updated, if this happens run (See [issue #109](https://github.com/outfoxxed/hy3/issues/109) for an example of where this happened) -```sh +```sh hyprpm update -f ``` From 3c42fae982bb9de0d5a7e6d9aa80942abf2737fb Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Thu, 20 Jun 2024 01:51:54 -0700 Subject: [PATCH 38/45] fix: reset node size when inserted into layout Fixes a bug that caused nodes with a non 1.0 size_ratio to offset other nodes in a workspace when moved from another workspace. --- CHANGELOG.md | 1 + src/Hy3Layout.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24bba97..0ee727c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ # Upcoming - Fixed glitchy tab bar effects when switching workspaces with fade effect. +- Fixed wrongly sized layout when moving resized nodes between workspaces. # hl0.41.0 and before diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 0bf5115..b05a5d6 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -126,6 +126,7 @@ void Hy3Layout::insertNode(Hy3Node& node) { } node.reparenting = true; + node.size_ratio = 1.0; auto* monitor = g_pCompositor->getMonitorFromID(node.workspace->m_iMonitorID); From 767eec5821cc8b7a4ccc60fa46ae809d4370e731 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 21 Jun 2024 13:34:07 -0700 Subject: [PATCH 39/45] version: updateto hyprland 0.41.1 --- CHANGELOG.md | 2 +- flake.lock | 33 ++++++++++++++++++--------------- flake.nix | 2 +- hyprpm.toml | 1 + 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ee727c..269fd39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -# Upcoming +# hl0.41.1 and before - Fixed glitchy tab bar effects when switching workspaces with fade effect. - Fixed wrongly sized layout when moving resized nodes between workspaces. diff --git a/flake.lock b/flake.lock index 512b8f8..a929c20 100644 --- a/flake.lock +++ b/flake.lock @@ -40,17 +40,16 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1718119065, - "narHash": "sha256-D/LR6g9JSHQBZhz5zBrQ6pyGiRr5nQx0JaJn1RlHFr4=", - "ref": "refs/heads/main", - "rev": "8c64a4bad710fb18e9b84812bd680a89d1e93661", - "revCount": 4800, + "lastModified": 1718272446, + "narHash": "sha256-hLnnNBWP1Qjs1I3fndMgp8rbWJruxdnGTq77A4Rv4R4=", + "rev": "9e781040d9067c2711ec2e9f5b47b76ef70762b3", + "revCount": 4818, "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" }, "original": { - "rev": "8c64a4bad710fb18e9b84812bd680a89d1e93661", + "rev": "9e781040d9067c2711ec2e9f5b47b76ef70762b3", "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" @@ -85,6 +84,10 @@ }, "hyprlang": { "inputs": { + "hyprutils": [ + "hyprland", + "hyprutils" + ], "nixpkgs": [ "hyprland", "nixpkgs" @@ -95,11 +98,11 @@ ] }, "locked": { - "lastModified": 1716473782, - "narHash": "sha256-+qLn4lsHU6iL3+HTo1gTQ1tWzet8K9h+IfVemzEQZj8=", + "lastModified": 1717881852, + "narHash": "sha256-XeeVoKHQgfKuXoP6q90sUqKyl7EYy3ol2dVZGM+Jj94=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "87d5d984109c839482b88b4795db073eb9ed446f", + "rev": "ec6938c66253429192274d612912649a0cfe4d28", "type": "github" }, "original": { @@ -160,11 +163,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1717602782, - "narHash": "sha256-pL9jeus5QpX5R+9rsp3hhZ+uplVHscNJh8n8VpqscM0=", + "lastModified": 1717974879, + "narHash": "sha256-GTO3C88+5DX171F/gVS3Qga/hOs/eRMxPFpiHq2t+D8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e8057b67ebf307f01bdcc8fba94d94f75039d1f6", + "rev": "c7b821ba2e1e635ba5a76d299af62821cbcb09f3", "type": "github" }, "original": { @@ -211,11 +214,11 @@ ] }, "locked": { - "lastModified": 1716290197, - "narHash": "sha256-1u9Exrc7yx9qtES2brDh7/DDZ8w8ap1nboIOAtCgeuM=", + "lastModified": 1717918856, + "narHash": "sha256-I38bmPLqamvOfVSArd1hhZtkVRAYBK38fOHZCU1P9Qg=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "91e48d6acd8a5a611d26f925e51559ab743bc438", + "rev": "72907822c19afc0983c69d59d299204381623725", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 035d90b..0f81af8 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=8c64a4bad710fb18e9b84812bd680a89d1e93661"; + hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=9e781040d9067c2711ec2e9f5b47b76ef70762b3"; }; outputs = { self, hyprland, ... }: let diff --git a/hyprpm.toml b/hyprpm.toml index 73e4c64..e06f8fe 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -12,6 +12,7 @@ commit_pins = [ ["fe7b748eb668136dd0558b7c8279bfcd7ab4d759", "6f9719291386d5e3baad211420d60e54e9967ee6"], ["cba1ade848feac44b2eda677503900639581c3f4", "584a1b1e357412a1a4ac40dbc6c4e5adaa7ec59b"], # 0.40.0 ["ea2501d4556f84d3de86a4ae2f4b22a474555b9f", "b6a777d2714628d2cda8843aec73a700ef269899"], # 0.41.0 + ["9e781040d9067c2711ec2e9f5b47b76ef70762b3", "b2c10c0f4d45aa6ef493f88c3eb0a20516fb9d2b"], # 0.41.1 ] [hy3] From d0056945d088c984232216c82e19428b9981fafc Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 24 Jun 2024 13:48:49 -0700 Subject: [PATCH 40/45] fixup: fix compile against hyprland 8a68199 --- flake.lock | 46 +++++++++++++++++++++++----------------------- flake.nix | 2 +- src/Hy3Layout.cpp | 27 ++++++++++++++------------- src/Hy3Node.cpp | 28 +++++++++++++--------------- src/TabGroup.cpp | 6 +++--- 5 files changed, 54 insertions(+), 55 deletions(-) diff --git a/flake.lock b/flake.lock index a929c20..7de4a6a 100644 --- a/flake.lock +++ b/flake.lock @@ -16,11 +16,11 @@ ] }, "locked": { - "lastModified": 1717181720, - "narHash": "sha256-yv+QZWsusu/NWjydkxixHC2g+tIJ9v+xkE2EiVpJj6g=", + "lastModified": 1718450675, + "narHash": "sha256-jpsns6buS4bK+1sF8sL8AaixAiCRjA+nldTKvcwmvUs=", "owner": "hyprwm", "repo": "hyprcursor", - "rev": "9e27a2c2ceb1e0b85bd55b0afefad196056fe87c", + "rev": "66d5b46ff94efbfa6fa3d1d1b66735f1779c34a6", "type": "github" }, "original": { @@ -40,16 +40,16 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1718272446, - "narHash": "sha256-hLnnNBWP1Qjs1I3fndMgp8rbWJruxdnGTq77A4Rv4R4=", - "rev": "9e781040d9067c2711ec2e9f5b47b76ef70762b3", - "revCount": 4818, + "lastModified": 1719164993, + "narHash": "sha256-FABhTnL6CBNrvsHVrEXWYoH+zrNfA4yPmgorQupUSZo=", + "rev": "8a68199a0ceb2894a5d9cc300961c38123ac0312", + "revCount": 4879, "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" }, "original": { - "rev": "9e781040d9067c2711ec2e9f5b47b76ef70762b3", + "rev": "8a68199a0ceb2894a5d9cc300961c38123ac0312", "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" @@ -69,11 +69,11 @@ ] }, "locked": { - "lastModified": 1691753796, - "narHash": "sha256-zOEwiWoXk3j3+EoF3ySUJmberFewWlagvewDRuWYAso=", + "lastModified": 1714869498, + "narHash": "sha256-vbLVOWvQqo4n1yvkg/Q70VTlPbMmTiCQfNTgcWDCfJM=", "owner": "hyprwm", "repo": "hyprland-protocols", - "rev": "0c2ce70625cb30aef199cb388f99e19a61a6ce03", + "rev": "e06482e0e611130cd1929f75e8c1cf679e57d161", "type": "github" }, "original": { @@ -123,11 +123,11 @@ ] }, "locked": { - "lastModified": 1717881334, - "narHash": "sha256-a0inRgJhPL6v9v7RPM/rx1kbXdfe3xJA1c9z0ZkYnh4=", + "lastModified": 1718804078, + "narHash": "sha256-CqRZne63BpYlPd/i8lXV0UInUt59oKogiwdVtBRHt60=", "owner": "hyprwm", "repo": "hyprutils", - "rev": "0693f9398ab693d89c9a0aa3b3d062dd61b7a60e", + "rev": "4f1351295c55a8f51219b25aa4a6497a067989d0", "type": "github" }, "original": { @@ -148,11 +148,11 @@ ] }, "locked": { - "lastModified": 1717784906, - "narHash": "sha256-YxmfxHfWed1fosaa7fC1u7XoKp1anEZU+7Lh/ojRKoM=", + "lastModified": 1718119275, + "narHash": "sha256-nqDYXATNkyGXVmNMkT19fT4sjtSPBDS1LLOxa3Fueo4=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "0f30f9eca6e404130988554accbb64d1c9ec877d", + "rev": "1419520d5f7f38d35e05504da5c1b38212a38525", "type": "github" }, "original": { @@ -163,11 +163,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1717974879, - "narHash": "sha256-GTO3C88+5DX171F/gVS3Qga/hOs/eRMxPFpiHq2t+D8=", + "lastModified": 1718530797, + "narHash": "sha256-pup6cYwtgvzDpvpSCFh1TEUjw2zkNpk8iolbKnyFmmU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c7b821ba2e1e635ba5a76d299af62821cbcb09f3", + "rev": "b60ebf54c15553b393d144357375ea956f89e9a9", "type": "github" }, "original": { @@ -214,11 +214,11 @@ ] }, "locked": { - "lastModified": 1717918856, - "narHash": "sha256-I38bmPLqamvOfVSArd1hhZtkVRAYBK38fOHZCU1P9Qg=", + "lastModified": 1718619174, + "narHash": "sha256-FWW68AVYmB91ZDQnhLMBNCUUTCjb1ZpO2k2KIytHtkA=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "72907822c19afc0983c69d59d299204381623725", + "rev": "c7894aa54f9a7dbd16df5cd24d420c8af22d5623", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 0f81af8..6d21cf4 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=9e781040d9067c2711ec2e9f5b47b76ef70762b3"; + hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=8a68199a0ceb2894a5d9cc300961c38123ac0312"; }; outputs = { self, hyprland, ... }: let diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index b05a5d6..a4f075e 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -549,14 +549,14 @@ void Hy3Layout::fullscreenRequestForWindow( // clang-format off auto gap_pos_offset = Vector2D( - -(gaps_in->left - gaps_out->left), - -(gaps_in->top - gaps_out->top) + (int) -(gaps_in->left - gaps_out->left), + (int) -(gaps_in->top - gaps_out->top) ); // clang-format on auto gap_size_offset = Vector2D( - -(gaps_in->left - gaps_out->left) + -(gaps_in->right - gaps_out->right), - -(gaps_in->top - gaps_out->top) + -(gaps_in->bottom - gaps_out->bottom) + (int) (-(gaps_in->left - gaps_out->left) + -(gaps_in->right - gaps_out->right)), + (int) (-(gaps_in->top - gaps_out->top) + -(gaps_in->bottom - gaps_out->bottom)) ); Hy3Node fakeNode = { @@ -968,15 +968,14 @@ void changeNodeWorkspaceRecursive(Hy3Node& node, const PHLWORKSPACE& workspace) } void Hy3Layout::moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsname, bool follow) { - std::string target_name; - auto target_id = getWorkspaceIDFromString(wsname, target_name); + auto target = getWorkspaceIDNameFromString(wsname); - if (target_id == WORKSPACE_INVALID) { + if (target.id == WORKSPACE_INVALID) { hy3_log(ERR, "moveNodeToWorkspace called with invalid workspace {}", wsname); return; } - auto workspace = g_pCompositor->getWorkspaceByID(target_id); + auto workspace = g_pCompositor->getWorkspaceByID(target.id); if (origin == workspace) return; @@ -991,9 +990,9 @@ void Hy3Layout::moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsna if (!valid(origin_ws)) return; if (workspace == nullptr) { - hy3_log(LOG, "creating target workspace {} for node move", target_id); + hy3_log(LOG, "creating target workspace {} for node move", target.id); - workspace = g_pCompositor->createNewWorkspace(target_id, origin_ws->m_iMonitorID, target_name); + workspace = g_pCompositor->createNewWorkspace(target.id, origin_ws->m_iMonitorID, target.name); } // floating or fullscreen @@ -1583,10 +1582,12 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { auto calcPos = window->m_vPosition; auto calcSize = window->m_vSize; - auto gaps_offset_topleft = Vector2D(gaps_in->left, gaps_in->top) + node->gap_topleft_offset; + auto gaps_offset_topleft = + Vector2D((int) gaps_in->left, (int) gaps_in->top) + node->gap_topleft_offset; + auto gaps_offset_bottomright = - Vector2D(gaps_in->left + gaps_in->right, gaps_in->top + gaps_in->bottom) - + node->gap_bottomright_offset + node->gap_topleft_offset; + Vector2D((int) (gaps_in->left + gaps_in->right), (int) (gaps_in->top + gaps_in->bottom)) + + node->gap_bottomright_offset + node->gap_topleft_offset; calcPos = calcPos + gaps_offset_topleft; calcSize = calcSize - gaps_offset_bottomright; diff --git a/src/Hy3Node.cpp b/src/Hy3Node.cpp index 5a9dd3d..32a9394 100644 --- a/src/Hy3Node.cpp +++ b/src/Hy3Node.cpp @@ -5,8 +5,8 @@ #include #include #include -#include #include +#include #include "Hy3Layout.hpp" #include "Hy3Node.hpp" @@ -304,17 +304,15 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { static const auto group_inset = ConfigValue("plugin:hy3:group_inset"); static const auto tab_bar_height = ConfigValue("plugin:hy3:tabs:height"); static const auto tab_bar_padding = ConfigValue("plugin:hy3:tabs:padding"); - // clang-format on - // clang-format off auto gap_topleft_offset = Vector2D( - -(gaps_in->left - gaps_out->left), - -(gaps_in->top - gaps_out->top) + (int) -(gaps_in->left - gaps_out->left), + (int) -(gaps_in->top - gaps_out->top) ); auto gap_bottomright_offset = Vector2D( - -(gaps_in->right - gaps_out->right), - -(gaps_in->bottom - gaps_out->bottom) + (int) -(gaps_in->right - gaps_out->right), + (int) -(gaps_in->bottom - gaps_out->bottom) ); // clang-format on @@ -447,16 +445,16 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { if (this->parent != nullptr) child->gap_bottomright_offset.x += *group_inset; } else if (child == group.children.front()) { child->gap_topleft_offset = gap_topleft_offset; - child->gap_bottomright_offset = Vector2D(0, gap_bottomright_offset.y); + child->gap_bottomright_offset = Vector2D(0.0, gap_bottomright_offset.y); child->size.x += gap_topleft_offset.x; offset += gap_topleft_offset.x; } else if (child == group.children.back()) { - child->gap_topleft_offset = Vector2D(0, gap_topleft_offset.y); + child->gap_topleft_offset = Vector2D(0.0, gap_topleft_offset.y); child->gap_bottomright_offset = gap_bottomright_offset; child->size.x += gap_bottomright_offset.x; } else { - child->gap_topleft_offset = Vector2D(0, gap_topleft_offset.y); - child->gap_bottomright_offset = Vector2D(0, gap_bottomright_offset.y); + child->gap_topleft_offset = Vector2D(0.0, gap_topleft_offset.y); + child->gap_bottomright_offset = Vector2D(0.0, gap_bottomright_offset.y); } child->recalcSizePosRecursive(no_animation); @@ -476,16 +474,16 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { if (this->parent != nullptr) child->gap_bottomright_offset.y += *group_inset; } else if (child == group.children.front()) { child->gap_topleft_offset = gap_topleft_offset; - child->gap_bottomright_offset = Vector2D(gap_bottomright_offset.x, 0); + child->gap_bottomright_offset = Vector2D(gap_bottomright_offset.x, 0.0); child->size.y += gap_topleft_offset.y; offset += gap_topleft_offset.y; } else if (child == group.children.back()) { - child->gap_topleft_offset = Vector2D(gap_topleft_offset.x, 0); + child->gap_topleft_offset = Vector2D(gap_topleft_offset.x, 0.0); child->gap_bottomright_offset = gap_bottomright_offset; child->size.y += gap_bottomright_offset.y; } else { - child->gap_topleft_offset = Vector2D(gap_topleft_offset.x, 0); - child->gap_bottomright_offset = Vector2D(gap_bottomright_offset.x, 0); + child->gap_topleft_offset = Vector2D(gap_topleft_offset.x, 0.0); + child->gap_bottomright_offset = Vector2D(gap_bottomright_offset.x, 0.0); } child->recalcSizePosRecursive(no_animation); diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 2e384bf..76184ee 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -4,15 +4,15 @@ #include #include #include -#include #include #include +#include #include +#include #include #include #include "globals.hpp" -#include "src/render/Texture.hpp" Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_bar), node(node) { this->focused @@ -419,7 +419,7 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { static const auto bar_height = ConfigValue("plugin:hy3:tabs:height"); auto& gaps = node.parent == nullptr ? gaps_out : gaps_in; - auto tpos = node.position + Vector2D(gaps->left, gaps->top) + node.gap_topleft_offset; + auto tpos = node.position + Vector2D((int) gaps->left, (int) gaps->top) + node.gap_topleft_offset; // clang-format off auto tsize = Vector2D( From df75070f7fbc1a894fb309dcbb4573034634d036 Mon Sep 17 00:00:00 2001 From: Nyslay Date: Mon, 24 Jun 2024 23:00:24 +0200 Subject: [PATCH 41/45] Add headers for build hy3 on openSuse distro (#127) * Add libs for build hy3 on openSuse distro * remove double space --------- Co-authored-by: nyslay --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4e83ac..832d21f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ if(CMAKE_EXPORT_COMPILE_COMMANDS) endif() find_package(PkgConfig REQUIRED) -pkg_check_modules(DEPS REQUIRED hyprland pixman-1 libdrm pango pangocairo) +pkg_check_modules(DEPS REQUIRED hyprland pixman-1 libdrm pango pangocairo libinput wayland-client xkbcommon) add_library(hy3 SHARED src/main.cpp From d200873687ea1f10958adb6c08cfcfa44b13267f Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Tue, 25 Jun 2024 11:57:39 -0700 Subject: [PATCH 42/45] version: update to hyprland 0.41.2 --- flake.lock | 28 ++++++++++++++-------------- flake.nix | 2 +- hyprpm.toml | 1 + 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/flake.lock b/flake.lock index 7de4a6a..f0efe60 100644 --- a/flake.lock +++ b/flake.lock @@ -40,16 +40,16 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1719164993, - "narHash": "sha256-FABhTnL6CBNrvsHVrEXWYoH+zrNfA4yPmgorQupUSZo=", - "rev": "8a68199a0ceb2894a5d9cc300961c38123ac0312", - "revCount": 4879, + "lastModified": 1719317162, + "narHash": "sha256-JmfnYz+9a4TjNl3mAus1VpoWtTI9d1xkW9MHbkcV0Po=", + "rev": "918d8340afd652b011b937d29d5eea0be08467f5", + "revCount": 4886, "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" }, "original": { - "rev": "8a68199a0ceb2894a5d9cc300961c38123ac0312", + "rev": "918d8340afd652b011b937d29d5eea0be08467f5", "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" @@ -123,11 +123,11 @@ ] }, "locked": { - "lastModified": 1718804078, - "narHash": "sha256-CqRZne63BpYlPd/i8lXV0UInUt59oKogiwdVtBRHt60=", + "lastModified": 1719316102, + "narHash": "sha256-dmRz128j/lJmMuTYeCYPfSBRHHQO3VeH4PbmoyAhHzw=", "owner": "hyprwm", "repo": "hyprutils", - "rev": "4f1351295c55a8f51219b25aa4a6497a067989d0", + "rev": "1f6bbec5954f623ff8d68e567bddcce97cd2f085", "type": "github" }, "original": { @@ -148,11 +148,11 @@ ] }, "locked": { - "lastModified": 1718119275, - "narHash": "sha256-nqDYXATNkyGXVmNMkT19fT4sjtSPBDS1LLOxa3Fueo4=", + "lastModified": 1719067853, + "narHash": "sha256-mAnZG/eQy72Fp1ImGtqCgUrDumnR1rMZv2E/zgP4U74=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "1419520d5f7f38d35e05504da5c1b38212a38525", + "rev": "914f083741e694092ee60a39d31f693d0a6dc734", "type": "github" }, "original": { @@ -163,11 +163,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1718530797, - "narHash": "sha256-pup6cYwtgvzDpvpSCFh1TEUjw2zkNpk8iolbKnyFmmU=", + "lastModified": 1719075281, + "narHash": "sha256-CyyxvOwFf12I91PBWz43iGT1kjsf5oi6ax7CrvaMyAo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b60ebf54c15553b393d144357375ea956f89e9a9", + "rev": "a71e967ef3694799d0c418c98332f7ff4cc5f6af", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 6d21cf4..800f181 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=8a68199a0ceb2894a5d9cc300961c38123ac0312"; + hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=918d8340afd652b011b937d29d5eea0be08467f5"; }; outputs = { self, hyprland, ... }: let diff --git a/hyprpm.toml b/hyprpm.toml index e06f8fe..1fc8630 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -13,6 +13,7 @@ commit_pins = [ ["cba1ade848feac44b2eda677503900639581c3f4", "584a1b1e357412a1a4ac40dbc6c4e5adaa7ec59b"], # 0.40.0 ["ea2501d4556f84d3de86a4ae2f4b22a474555b9f", "b6a777d2714628d2cda8843aec73a700ef269899"], # 0.41.0 ["9e781040d9067c2711ec2e9f5b47b76ef70762b3", "b2c10c0f4d45aa6ef493f88c3eb0a20516fb9d2b"], # 0.41.1 + ["918d8340afd652b011b937d29d5eea0be08467f5", "df75070f7fbc1a894fb309dcbb4573034634d036"], # 0.41.2 ] [hy3] From 4f06a1286a2740035debb89bc01789f61e068d65 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sat, 13 Jul 2024 22:37:44 -0700 Subject: [PATCH 43/45] use CBox over wlr_box in preparation for aq backend WLR will be removed in the future so wlr_box is not safe to use. --- src/TabGroup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 76184ee..ab5741d 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -533,7 +533,7 @@ void Hy3TabGroup::renderTabBar() { auto scaled_pos = Vector2D(std::round(pos.x * scale), std::round(pos.y * scale)); auto scaled_size = Vector2D(std::round(size.x * scale), std::round(size.y * scale)); - wlr_box box = {scaled_pos.x, scaled_pos.y, scaled_size.x, scaled_size.y}; + CBox box = {scaled_pos.x, scaled_pos.y, scaled_size.x, scaled_size.y}; // monitor size is not scaled if (pos.x > monitor_size.x || pos.y > monitor_size.y || scaled_pos.x + scaled_size.x < 0 From a19f3b5e06b1bb66bd78ba0b46210ddadae43a3c Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sat, 13 Jul 2024 22:58:01 -0700 Subject: [PATCH 44/45] fixup: fix compile against hyprland after hyprland#6776 Fixes #133 --- flake.lock | 11 ++++++----- flake.nix | 2 +- src/Hy3Layout.cpp | 23 +++++++++-------------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index f0efe60..7597828 100644 --- a/flake.lock +++ b/flake.lock @@ -40,16 +40,17 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1719317162, - "narHash": "sha256-JmfnYz+9a4TjNl3mAus1VpoWtTI9d1xkW9MHbkcV0Po=", - "rev": "918d8340afd652b011b937d29d5eea0be08467f5", - "revCount": 4886, + "lastModified": 1720896272, + "narHash": "sha256-zo1lDMsxjEyko/P+KfCLNYZrCAWQOrX90/J31nqzpy4=", + "ref": "refs/heads/main", + "rev": "bc6b0880dda2607a80f000c134f573c970452a0f", + "revCount": 4925, "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" }, "original": { - "rev": "918d8340afd652b011b937d29d5eea0be08467f5", + "rev": "bc6b0880dda2607a80f000c134f573c970452a0f", "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" diff --git a/flake.nix b/flake.nix index 800f181..bfac52e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=918d8340afd652b011b937d29d5eea0be08467f5"; + hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=bc6b0880dda2607a80f000c134f573c970452a0f"; }; outputs = { self, hyprland, ... }: let diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index a4f075e..6f65e73 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -12,6 +12,7 @@ #include "Hy3Node.hpp" #include "SelectionHook.hpp" #include "globals.hpp" +#include "src/desktop/Window.hpp" SP renderHookPtr; SP windowTitleHookPtr; @@ -300,9 +301,7 @@ void Hy3Layout::onWindowRemovedTiling(PHLWINDOW window) { (uintptr_t) node->parent ); - window->m_sSpecialRenderData.rounding = true; - window->m_sSpecialRenderData.border = true; - window->m_sSpecialRenderData.decorate = true; + window->unsetWindowData(PRIORITY_LAYOUT); if (window->m_bIsFullscreen) { g_pCompositor->setWindowFullscreen(window, false, FULLSCREEN_FULL); @@ -521,9 +520,7 @@ void Hy3Layout::fullscreenRequestForWindow( window->m_vRealPosition = window->m_vLastFloatingPosition; window->m_vRealSize = window->m_vLastFloatingSize; - window->m_sSpecialRenderData.rounding = true; - window->m_sSpecialRenderData.border = true; - window->m_sSpecialRenderData.decorate = true; + window->unsetWindowData(PRIORITY_LAYOUT); } } else { window->m_pWorkspace->m_efFullscreenMode = fullscreen_mode; @@ -638,7 +635,7 @@ PHLWINDOW Hy3Layout::getNextWindowCandidate(PHLWINDOW window) { for (auto& w: g_pCompositor->m_vWindows | std::views::reverse) { if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_pWorkspace == window->m_pWorkspace && !w->m_bX11ShouldntFocus - && !w->m_sAdditionalConfigData.noFocus && w != window) + && !w->m_sWindowData.noFocus.valueOrDefault() && w != window) { return w; } @@ -1529,8 +1526,6 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { return; } - const auto workspace_rule = g_pConfigManager->getWorkspaceRuleFor(node->workspace); - // clang-format off static const auto gaps_in = ConfigValue("general:gaps_in"); static const auto no_gaps_when_only = ConfigValue("plugin:hy3:no_gaps_when_only"); @@ -1549,7 +1544,7 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { return; } - window->updateSpecialRenderData(); + window->unsetWindowData(PRIORITY_LAYOUT); auto nodeBox = CBox(node->position, node->size); nodeBox.round(); @@ -1565,10 +1560,10 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { || (window->m_bIsFullscreen && window->m_pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL ))) { - window->m_sSpecialRenderData.border = workspace_rule.border.value_or(*no_gaps_when_only == 2); - - window->m_sSpecialRenderData.rounding = false; - window->m_sSpecialRenderData.shadow = false; + window->m_sWindowData.decorate = CWindowOverridableVar(true, PRIORITY_LAYOUT); // a little curious but copying what dwindle does + window->m_sWindowData.noBorder = CWindowOverridableVar(*no_gaps_when_only != 2, PRIORITY_LAYOUT); + window->m_sWindowData.noRounding = CWindowOverridableVar(true, PRIORITY_LAYOUT); + window->m_sWindowData.noShadow = CWindowOverridableVar(true, PRIORITY_LAYOUT); window->updateWindowDecos(); From df42a80827c2c3331c6f612eb86464d67ba55e50 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 21 Jul 2024 11:22:09 -0700 Subject: [PATCH 45/45] nix: fix nix build against props.json change --- flake.lock | 86 +++++++++++++++++++++++++++++++++++++----------------- flake.nix | 10 +++---- 2 files changed, 65 insertions(+), 31 deletions(-) diff --git a/flake.lock b/flake.lock index 7597828..50bae08 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,38 @@ { "nodes": { + "aquamarine": { + "inputs": { + "hyprutils": [ + "hyprland", + "hyprutils" + ], + "hyprwayland-scanner": [ + "hyprland", + "hyprwayland-scanner" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1721487522, + "narHash": "sha256-aF3uwUwUK2CgbItoMe3IJF0yidIEWcDx47AiH5y8VKk=", + "owner": "hyprwm", + "repo": "aquamarine", + "rev": "acfea3bd1d9e756c7152e639240d52c6628844b0", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "aquamarine", + "type": "github" + } + }, "hyprcursor": { "inputs": { "hyprlang": [ @@ -16,11 +49,11 @@ ] }, "locked": { - "lastModified": 1718450675, - "narHash": "sha256-jpsns6buS4bK+1sF8sL8AaixAiCRjA+nldTKvcwmvUs=", + "lastModified": 1720108799, + "narHash": "sha256-AxRkTJlbB8r7aG6gvc7IaLhc2T9TO4/8uqanKRxukBQ=", "owner": "hyprwm", "repo": "hyprcursor", - "rev": "66d5b46ff94efbfa6fa3d1d1b66735f1779c34a6", + "rev": "a5c0d57325c5f0814c39110a70ca19c070ae9486", "type": "github" }, "original": { @@ -31,6 +64,7 @@ }, "hyprland": { "inputs": { + "aquamarine": "aquamarine", "hyprcursor": "hyprcursor", "hyprlang": "hyprlang", "hyprutils": "hyprutils", @@ -40,17 +74,17 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1720896272, - "narHash": "sha256-zo1lDMsxjEyko/P+KfCLNYZrCAWQOrX90/J31nqzpy4=", + "lastModified": 1721579057, + "narHash": "sha256-x/RIzkL8PwLDNiRV/R308RdCmS8h3G9Xf62XVH/WAp0=", "ref": "refs/heads/main", - "rev": "bc6b0880dda2607a80f000c134f573c970452a0f", - "revCount": 4925, + "rev": "928d1dd38a6e4a791d4a4374a4a3bf02311adbb2", + "revCount": 4942, "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" }, "original": { - "rev": "bc6b0880dda2607a80f000c134f573c970452a0f", + "rev": "928d1dd38a6e4a791d4a4374a4a3bf02311adbb2", "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" @@ -70,11 +104,11 @@ ] }, "locked": { - "lastModified": 1714869498, - "narHash": "sha256-vbLVOWvQqo4n1yvkg/Q70VTlPbMmTiCQfNTgcWDCfJM=", + "lastModified": 1718746314, + "narHash": "sha256-HUklK5u86w2Yh9dOkk4FdsL8eehcOZ95jPhLixGDRQY=", "owner": "hyprwm", "repo": "hyprland-protocols", - "rev": "e06482e0e611130cd1929f75e8c1cf679e57d161", + "rev": "1b61f0093afff20ab44d88ad707aed8bf2215290", "type": "github" }, "original": { @@ -99,11 +133,11 @@ ] }, "locked": { - "lastModified": 1717881852, - "narHash": "sha256-XeeVoKHQgfKuXoP6q90sUqKyl7EYy3ol2dVZGM+Jj94=", + "lastModified": 1720381373, + "narHash": "sha256-lyC/EZdHULsaAKVryK11lgHY9u6pXr7qR4irnxNWC7k=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "ec6938c66253429192274d612912649a0cfe4d28", + "rev": "5df0174fd09de4ac5475233d65ffc703e89b82eb", "type": "github" }, "original": { @@ -124,11 +158,11 @@ ] }, "locked": { - "lastModified": 1719316102, - "narHash": "sha256-dmRz128j/lJmMuTYeCYPfSBRHHQO3VeH4PbmoyAhHzw=", + "lastModified": 1721071737, + "narHash": "sha256-qmC9jGfbE4+EIBbbSAkrfR/p49wShjpv4/KztgE/P54=", "owner": "hyprwm", "repo": "hyprutils", - "rev": "1f6bbec5954f623ff8d68e567bddcce97cd2f085", + "rev": "eb1ceff2b87f6820789249f63faa8e9dcb54d05f", "type": "github" }, "original": { @@ -149,11 +183,11 @@ ] }, "locked": { - "lastModified": 1719067853, - "narHash": "sha256-mAnZG/eQy72Fp1ImGtqCgUrDumnR1rMZv2E/zgP4U74=", + "lastModified": 1720215857, + "narHash": "sha256-JPdL+Qul+jEueAn8CARfcWP83eJgwkhMejQYfDvrgvU=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "914f083741e694092ee60a39d31f693d0a6dc734", + "rev": "d5fa094ca27e0039be5e94c0a80ae433145af8bb", "type": "github" }, "original": { @@ -164,11 +198,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1719075281, - "narHash": "sha256-CyyxvOwFf12I91PBWz43iGT1kjsf5oi6ax7CrvaMyAo=", + "lastModified": 1720957393, + "narHash": "sha256-oedh2RwpjEa+TNxhg5Je9Ch6d3W1NKi7DbRO1ziHemA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a71e967ef3694799d0c418c98332f7ff4cc5f6af", + "rev": "693bc46d169f5af9c992095736e82c3488bf7dbb", "type": "github" }, "original": { @@ -215,11 +249,11 @@ ] }, "locked": { - "lastModified": 1718619174, - "narHash": "sha256-FWW68AVYmB91ZDQnhLMBNCUUTCjb1ZpO2k2KIytHtkA=", + "lastModified": 1720194466, + "narHash": "sha256-Rizg9efi6ue95zOp0MeIV2ZedNo+5U9G2l6yirgBUnA=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "c7894aa54f9a7dbd16df5cd24d420c8af22d5623", + "rev": "b9b97e5ba23fe7bd5fa4df54696102e8aa863cf6", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index bfac52e..9fd2257 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=bc6b0880dda2607a80f000c134f573c970452a0f"; + hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=928d1dd38a6e4a791d4a4374a4a3bf02311adbb2"; }; outputs = { self, hyprland, ... }: let @@ -10,12 +10,12 @@ (builtins.attrNames hyprland.packages) (system: fn system nixpkgs.legacyPackages.${system}); - props = builtins.fromJSON (builtins.readFile "${hyprland}/props.json"); + hyprlandVersion = nixpkgs.lib.removeSuffix "\n" (builtins.readFile "${hyprland}/VERSION"); in { packages = hyprlandSystems (system: pkgs: rec { hy3 = pkgs.callPackage ./default.nix { hyprland = hyprland.packages.${system}.hyprland; - hlversion = props.version; + hlversion = hyprlandVersion; }; default = hy3; }); @@ -23,13 +23,13 @@ devShells = hyprlandSystems (system: pkgs: { default = import ./shell.nix { inherit pkgs; - hlversion = props.version; + hlversion = hyprlandVersion; hyprland = hyprland.packages.${system}.hyprland-debug; }; impure = import ./shell.nix { pkgs = import {}; - hlversion = props.version; + hlversion = hyprlandVersion; hyprland = (pkgs.appendOverlays [ hyprland.overlays.hyprland-packages ]).hyprland-debug.overrideAttrs { dontStrip = true; };