From 3924816ba2370c8c1416947255da5d7ae7d0186b Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Tue, 5 Mar 2024 01:58:34 -0800 Subject: [PATCH 1/7] Update flake to hyprland 0.36.0 --- flake.lock | 46 ++++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/flake.lock b/flake.lock index 0abb1d4..c450cf5 100644 --- a/flake.lock +++ b/flake.lock @@ -10,12 +10,13 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1708650152, - "narHash": "sha256-OZUS5FED7KKAPpNaJYQr4BPGXQzGrDFgkKVg9U2aZh8=", - "owner": "hyprwm", - "repo": "Hyprland", - "rev": "8c3613632a6ccebf9fb797ec756ecfce99514eec", - "type": "github" + "lastModified": 1709080360, + "narHash": "sha256-oZe4k6jtO/0govmERGcbeyvE9EfTvXY5bnyIs6AsL9U=", + "ref": "v0.36.0", + "rev": "1c460e98f870676b15871fe4e5bfeb1a32a3d6d8", + "revCount": 4102, + "type": "git", + "url": "file:///home/admin/programming/outfoxxed/hyprland/Hyprland" }, "original": { "owner": "hyprwm", @@ -69,35 +70,13 @@ "type": "github" } }, - "hyprlang_2": { - "inputs": { - "nixpkgs": [ - "hyprland", - "xdph", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1704287638, - "narHash": "sha256-TuRXJGwtK440AXQNl5eiqmQqY4LZ/9+z/R7xC0ie3iA=", - "owner": "hyprwm", - "repo": "hyprlang", - "rev": "6624f2bb66d4d27975766e81f77174adbe58ec97", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprlang", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1707546158, - "narHash": "sha256-nYYJTpzfPMDxI8mzhQsYjIUX+grorqjKEU9Np6Xwy/0=", + "lastModified": 1709479366, + "narHash": "sha256-n6F0n8UV6lnTZbYPl1A9q1BS0p4hduAv1mGAP17CVd0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d934204a0f8d9198e1e4515dd6fec76a139c87f0", + "rev": "b8697e57f10292a6165a20f03d2f42920dfaf973", "type": "github" }, "original": { @@ -152,7 +131,10 @@ "hyprland", "hyprland-protocols" ], - "hyprlang": "hyprlang_2", + "hyprlang": [ + "hyprland", + "hyprlang" + ], "nixpkgs": [ "hyprland", "nixpkgs" From c880e0f00946273ee0304bba9c1de276062d496f Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Tue, 5 Mar 2024 03:13:50 -0800 Subject: [PATCH 2/7] Improve build process and nix scripts --- .gitignore | 20 +++++++++++++++---- default.nix | 51 +++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 57 ++++++++++++++++++----------------------------------- hyprpm.toml | 2 +- shell.nix | 16 +++++++++++++++ 5 files changed, 103 insertions(+), 43 deletions(-) create mode 100644 default.nix create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index 36b6e89..5862322 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,16 @@ -build/ -compile_commands.json -.vscode/ -*.log +# build +/result +/build/ +/compile_commands.json + +# clangd +/.cache + +# direnv +/.envrc +/.direnv/ + +# vscode +/.vscode/ + +/*.log diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..1925ec5 --- /dev/null +++ b/default.nix @@ -0,0 +1,51 @@ +{ + hyprland, + + lib, + nix-gitignore, + keepDebugInfo, + stdenv ? (keepDebugInfo hyprland.stdenv), + + cmake, + ninja, + pkg-config, + pango, + cairo, + + debug ? false, + hlversion ? "git", + versionCheck ? true, +}: stdenv.mkDerivation { + pname = "hy3"; + version = "hl${hlversion}${lib.optionalString debug "-debug"}"; + src = nix-gitignore.gitignoreSource [] ./.; + + nativeBuildInputs = [ + cmake + ninja + pkg-config + ]; + + buildInputs = [ + hyprland.dev + pango + cairo + ] ++ hyprland.buildInputs; + + cmakeFlags = lib.optional (!versionCheck) "-DHY3_NO_VERSION_CHECK=ON"; + + cmakeBuildType = if debug + then "Debug" + else "RelWithDebInfo"; + + buildPhase = "ninjaBuildPhase"; + enableParallelBuilding = true; + dontStrip = true; + + meta = with lib; { + homepage = "https://github.com/outfoxxed/hy3"; + description = "Hyprland plugin for an i3 like manual tiling layout"; + license = licenses.gpl3; + platforms = platforms.linux; + }; +} diff --git a/flake.nix b/flake.nix index a250f37..a375308 100644 --- a/flake.nix +++ b/flake.nix @@ -5,51 +5,32 @@ outputs = { self, hyprland, ... }: let inherit (hyprland.inputs) nixpkgs; - hyprlandSystems = fn: nixpkgs.lib.genAttrs (builtins.attrNames hyprland.packages) (system: fn system nixpkgs.legacyPackages.${system}); + + hyprlandSystems = fn: nixpkgs.lib.genAttrs + (builtins.attrNames hyprland.packages) + (system: fn system nixpkgs.legacyPackages.${system}); + + props = builtins.fromJSON (builtins.readFile "${hyprland}/props.json"); in { - packages = hyprlandSystems (system: pkgs: let - hyprlandPackage = hyprland.packages.${system}.hyprland; - in rec { - hy3 = hyprlandPackage.stdenv.mkDerivation { - pname = "hy3"; - version = "0.1"; - src = ./.; - - nativeBuildInputs = with pkgs; [ cmake pkg-config ]; - - buildInputs = with pkgs; [ - hyprlandPackage.dev - pango - cairo - ] ++ hyprlandPackage.buildInputs; - - # no noticeable impact on performance and greatly assists debugging - cmakeBuildType = "Debug"; - dontStrip = true; - - meta = with pkgs.lib; { - homepage = "https://github.com/outfoxxed/hy3"; - description = "Hyprland plugin for an i3 / sway like manual tiling layout"; - license = licenses.gpl3; - platforms = platforms.linux; - }; + packages = hyprlandSystems (system: pkgs: rec { + hy3 = pkgs.callPackage ./default.nix { + hyprland = hyprland.packages.${system}.hyprland; + hlversion = props.version; }; - default = hy3; }); devShells = hyprlandSystems (system: pkgs: { - default = pkgs.mkShell.override { - stdenv = pkgs.gcc13Stdenv; - } { - name = "hy3"; + default = import ./shell.nix { + inherit pkgs; + hlversion = props.version; + hyprland = hyprland.packages.${system}.hyprland-debug; + }; - nativeBuildInputs = with pkgs; [ - clang-tools_17 - bear - ]; - - inputsFrom = [ self.packages.${system}.hy3 ]; + impure = import ./shell.nix { + pkgs = import {}; + hlversion = props.version; + hyprland = (pkgs.appendOverlays [ hyprland.overlays.hyprland-packages ]).hyprland-debug; }; }); }; diff --git a/hyprpm.toml b/hyprpm.toml index 012b379..b7178b2 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -11,6 +11,6 @@ description = "i3 like tiling for hyprland" authors = ["outfoxxed"] output = "build/libhy3.so" build = [ - "cmake -DCMAKE_BUILD_TYPE=Release -B build", + "cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -B build", "cmake --build build" ] diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..1cd716e --- /dev/null +++ b/shell.nix @@ -0,0 +1,16 @@ +{ + hyprland, + pkgs, + hlversion ? "git", + hy3 ? pkgs.callPackage ./default.nix { + inherit hyprland hlversion; + versionCheck = false; + }, +}: pkgs.mkShell { + inputsFrom = [ hy3 ]; + + nativeBuildInputs = with pkgs; [ + clang-tools_17 + bear + ]; +} From bff967850ef98ef685ec997d2e775a6d970745e8 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Tue, 5 Mar 2024 03:15:16 -0800 Subject: [PATCH 3/7] Bump hyprpm for hl0.36.0 --- hyprpm.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hyprpm.toml b/hyprpm.toml index b7178b2..f1ba8c9 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -3,7 +3,8 @@ name = "hy3" authors = ["outfoxxed"] commit_pins = [ ["03ebbe18ed8517ee22591eac82cd54322f42cb7d", "2f28dc810c0e1f42763a1f14fb011c4fce6db8be"], - ["84ab8d11e8951a6551d1e1bf87796a8589da6d47", "d3e20856a9896f28b506195b31407eddc6df2e20"] + ["84ab8d11e8951a6551d1e1bf87796a8589da6d47", "d3e20856a9896f28b506195b31407eddc6df2e20"], + ["1c460e98f870676b15871fe4e5bfeb1a32a3d6d8", "c880e0f00946273ee0304bba9c1de276062d496f"] ] [hy3] From ca20df2f178b01fabd33d7fb5db06aa25b45222d Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Tue, 5 Mar 2024 03:17:59 -0800 Subject: [PATCH 4/7] Fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c97a0bf..3ad188b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Upcoming +## hl0.36.0 and before - Implement `resizeactivewindow` for floating windows - Fully implement `resizeactivewindow` for tiled windows From a392bfd13caf865ccf6b9df6917b67cc3a054b82 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 6 Mar 2024 02:02:07 -0800 Subject: [PATCH 5/7] Fix breakage after hyprland#4911 --- flake.lock | 13 ++++--- src/Hy3Layout.cpp | 22 ++++++------ src/TabGroup.cpp | 90 +++++++++++++++++++++++------------------------ src/TabGroup.hpp | 18 +++++----- 4 files changed, 71 insertions(+), 72 deletions(-) diff --git a/flake.lock b/flake.lock index c450cf5..cbaba3e 100644 --- a/flake.lock +++ b/flake.lock @@ -10,13 +10,12 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1709080360, - "narHash": "sha256-oZe4k6jtO/0govmERGcbeyvE9EfTvXY5bnyIs6AsL9U=", - "ref": "v0.36.0", - "rev": "1c460e98f870676b15871fe4e5bfeb1a32a3d6d8", - "revCount": 4102, - "type": "git", - "url": "file:///home/admin/programming/outfoxxed/hyprland/Hyprland" + "lastModified": 1709339717, + "narHash": "sha256-VXh6tiY1+Tmaz+dgUNE5IpWaFq4wbf/iCTHclGm33vA=", + "owner": "hyprwm", + "repo": "Hyprland", + "rev": "b2c34404777ea0850f90f4c38f64484f03599d14", + "type": "github" }, "original": { "owner": "hyprwm", diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 14b3c9b..2b0fb0f 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -487,8 +487,8 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, eRectCorner corner, CW } else if (window->m_bIsFloating) { // No parent node - is this a floating window? If so, use the same logic as the `main` layout const auto required_size = Vector2D( - std::max((window->m_vRealSize.goalv() + delta).x, 20.0), - std::max((window->m_vRealSize.goalv() + delta).y, 20.0) + std::max((window->m_vRealSize.goal() + delta).x, 20.0), + std::max((window->m_vRealSize.goal() + delta).y, 20.0) ); window->m_vRealSize = required_size; } @@ -530,10 +530,10 @@ void Hy3Layout::fullscreenRequestForWindow( // save position and size if floating if (window->m_bIsFloating) { - window->m_vLastFloatingPosition = window->m_vRealPosition.goalv(); - window->m_vPosition = window->m_vRealPosition.goalv(); - window->m_vLastFloatingSize = window->m_vRealSize.goalv(); - window->m_vSize = window->m_vRealSize.goalv(); + window->m_vLastFloatingPosition = window->m_vRealPosition.goal(); + window->m_vPosition = window->m_vRealPosition.goal(); + window->m_vLastFloatingSize = window->m_vRealSize.goal(); + window->m_vSize = window->m_vRealSize.goal(); } if (fullscreen_mode == FULLSCREEN_FULL) { @@ -573,7 +573,7 @@ void Hy3Layout::fullscreenRequestForWindow( } g_pCompositor->updateWindowAnimatedDecorationValues(window); - g_pXWaylandManager->setWindowSize(window, window->m_vRealSize.goalv()); + g_pXWaylandManager->setWindowSize(window, window->m_vRealSize.goal()); g_pCompositor->changeWindowZOrder(window, true); this->recalculateMonitor(monitor->ID); } @@ -1085,14 +1085,14 @@ Hy3Node* findTabBarAt(Hy3Node& node, Vector2D pos, Hy3Node** focused_node) { auto& children = node.data.as_group.children; auto& tab_bar = *node.data.as_group.tab_bar; - auto size = tab_bar.size.vec(); - auto x = pos.x - tab_bar.pos.vec().x; + auto size = tab_bar.size.value(); + auto x = pos.x - tab_bar.pos.value().x; auto child_iter = children.begin(); for (auto& tab: tab_bar.bar.entries) { if (child_iter == children.end()) break; - if (x > tab.offset.fl() * size.x && x < (tab.offset.fl() + tab.width.fl()) * size.x) { + if (x > tab.offset.value() * size.x && x < (tab.offset.value() + tab.width.value()) * size.x) { *focused_node = *child_iter; return &node; } @@ -1316,7 +1316,7 @@ fullscreen: // goto fsupdate; fsupdate: g_pCompositor->updateWindowAnimatedDecorationValues(window); - g_pXWaylandManager->setWindowSize(window, window->m_vRealSize.goalv()); + g_pXWaylandManager->setWindowSize(window, window->m_vRealSize.goal()); g_pCompositor->changeWindowZOrder(window, true); this->recalculateMonitor(monitor->ID); } diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index e7049fb..c79d089 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -12,7 +12,6 @@ Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_bar), node(node) { this->focused.create( - AVARTYPE_FLOAT, 0.0f, g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"), nullptr, @@ -20,7 +19,6 @@ Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_b ); this->urgent.create( - AVARTYPE_FLOAT, 0.0f, g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"), nullptr, @@ -28,7 +26,6 @@ Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_b ); this->offset.create( - AVARTYPE_FLOAT, -1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, @@ -36,7 +33,6 @@ Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_b ); this->width.create( - AVARTYPE_FLOAT, -1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, @@ -44,7 +40,6 @@ Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_b ); this->vertical_pos.create( - AVARTYPE_FLOAT, 1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), nullptr, @@ -52,13 +47,17 @@ Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_b ); this->fade_opacity.create( - AVARTYPE_FLOAT, 0.0f, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), nullptr, AVARDAMAGE_NONE ); + // !!! Can be removed after hyprland#4992 + this->offset = -1.0f; + this->width = -1.0f; + this->vertical_pos = 1.0f; + this->focused.registerVar(); this->urgent.registerVar(); this->offset.registerVar(); @@ -89,14 +88,14 @@ bool Hy3TabBarEntry::operator==(const Hy3TabBarEntry& entry) const { } void Hy3TabBarEntry::setFocused(bool focused) { - if (this->focused.goalf() != focused) { + if (this->focused.goal() != focused) { this->focused = focused; } } void Hy3TabBarEntry::setUrgent(bool urgent) { - if (urgent && this->focused.goalf() == 1.0) urgent = false; - if (this->urgent.goalf() != urgent) { + if (urgent && this->focused.goal() == 1.0) urgent = false; + if (this->urgent.goal() != urgent) { this->urgent = urgent; } } @@ -121,7 +120,7 @@ void Hy3TabBarEntry::unDestroy() { } bool Hy3TabBarEntry::shouldRemove() { - return this->destroying && (this->vertical_pos.fl() == 1.0 || this->width.fl() == 0.0); + return this->destroying && (this->vertical_pos.value() == 1.0 || this->width.value() == 0.0); } void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) { @@ -149,8 +148,8 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) { // clang-format off || this->last_render.x != box.x || this->last_render.y != box.y - || this->last_render.focused != this->focused.fl() - || this->last_render.urgent != this->urgent.fl() + || this->last_render.focused != this->focused.value() + || this->last_render.urgent != this->urgent.value() || this->last_render.window_title != this->window_title || this->last_render.rounding != rounding || this->last_render.text_font != *text_font @@ -167,8 +166,8 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) { { this->last_render.x = box.x; this->last_render.y = box.y; - this->last_render.focused = this->focused.fl(); - this->last_render.urgent = this->urgent.fl(); + this->last_render.focused = this->focused.value(); + this->last_render.urgent = this->urgent.value(); this->last_render.window_title = this->window_title; this->last_render.rounding = rounding; this->last_render.text_font = *text_font; @@ -191,8 +190,8 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) { cairo_restore(cairo); // set brush - auto focused = this->focused.fl(); - auto urgent = this->urgent.fl(); + auto focused = this->focused.value(); + auto urgent = this->urgent.value(); auto inactive = 1.0 - (focused + urgent); auto c = (CColor(*col_active) * focused) + (CColor(*col_urgent) * urgent) + (CColor(*col_inactive) * inactive); @@ -278,13 +277,15 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) { Hy3TabBar::Hy3TabBar() { this->fade_opacity.create( - AVARTYPE_FLOAT, 1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE ); + // !!! Can be removed after hyprland#4992 + this->fade_opacity = 1.0f; + this->fade_opacity.registerVar(); this->fade_opacity.setUpdateCallback([this](void*) { this->dirty = true; }); } @@ -396,29 +397,30 @@ void Hy3TabBar::updateAnimations(bool warp) { auto entry = this->entries.begin(); while (entry != this->entries.end()) { if (warp) { - if (entry->width.goalf() == 0.0) { - this->entries.erase(entry++); + if (entry->width.goal() == 0.0) { + //this->entries.erase(entry++); + entry = std::next(entry); continue; } entry->offset.setValueAndWarp(offset); entry->width.setValueAndWarp(entry_width); } else { - auto warp_init = entry->offset.goalf() == -1.0; + auto warp_init = entry->offset.goal() == -1.0; if (warp_init) { entry->offset.setValueAndWarp(offset); - entry->width.setValueAndWarp(entry->vertical_pos.fl() == 0.0 ? 0.0 : entry_width); + entry->width.setValueAndWarp(entry->vertical_pos.value() == 0.0 ? 0.0 : entry_width); } if (!entry->destroying) { - if (entry->offset.goalf() != offset) entry->offset = offset; - if ((warp_init || entry->width.goalf() != 0.0) && entry->width.goalf() != entry_width) + if (entry->offset.goal() != offset) entry->offset = offset; + if ((warp_init || entry->width.goal() != 0.0) && entry->width.goal() != entry_width) entry->width = entry_width; } } - if (!entry->destroying) offset += entry->width.goalf(); + if (!entry->destroying) offset += entry->width.goal(); entry = std::next(entry); } } @@ -430,14 +432,12 @@ void Hy3TabBar::setSize(Vector2D size) { Hy3TabGroup::Hy3TabGroup(Hy3Node& node) { this->pos.create( - AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE ); this->size.create( - AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE @@ -467,12 +467,12 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { // clang-format on this->hidden = node.hidden; - if (this->pos.goalv() != tpos) { + if (this->pos.goal() != tpos) { this->pos = tpos; if (warp) this->pos.warp(); } - if (this->size.goalv() != tsize) { + if (this->size.goal() != tsize) { this->size = tsize; if (warp) this->size.warp(); } @@ -494,14 +494,14 @@ void Hy3TabGroup::tick() { if (workspace != nullptr) { if (workspace->m_bHasFullscreenWindow) { - if (this->bar.fade_opacity.goalf() != 0.0) this->bar.fade_opacity = 0.0; + if (this->bar.fade_opacity.goal() != 0.0) this->bar.fade_opacity = 0.0; } else { - if (this->bar.fade_opacity.goalf() != 1.0) this->bar.fade_opacity = 1.0; + if (this->bar.fade_opacity.goal() != 1.0) this->bar.fade_opacity = 1.0; } } - auto pos = this->pos.vec(); - auto size = this->size.vec(); + auto pos = this->pos.value(); + 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}; @@ -537,11 +537,11 @@ void Hy3TabGroup::renderTabBar() { auto scale = monitor->scale; auto monitor_size = monitor->vecSize; - auto pos = this->pos.vec() - monitor->vecPosition; - auto size = this->size.vec(); + auto pos = this->pos.value() - monitor->vecPosition; + auto size = this->size.value(); if (workspace != nullptr) { - pos = pos + workspace->m_vRenderOffset.vec(); + pos = pos + workspace->m_vRenderOffset.value(); } auto scaled_pos = Vector2D(std::round(pos.x * scale), std::round(pos.y * scale)); @@ -588,8 +588,8 @@ void Hy3TabGroup::renderTabBar() { for (auto* window: this->stencil_windows) { if (!g_pCompositor->windowExists(window)) continue; - auto wpos = window->m_vRealPosition.vec() - monitor->vecPosition; - auto wsize = window->m_vRealSize.vec(); + auto wpos = window->m_vRealPosition.value() - monitor->vecPosition; + auto wsize = window->m_vRealSize.value(); CBox window_box = {wpos.x, wpos.y, wsize.x, wsize.y}; // scaleBox(&window_box, scale); @@ -607,16 +607,16 @@ void Hy3TabGroup::renderTabBar() { } auto fade_opacity = - this->bar.fade_opacity.fl() * (workspace == nullptr ? 1.0 : workspace->m_fAlpha.fl()); + this->bar.fade_opacity.value() * (workspace == nullptr ? 1.0 : workspace->m_fAlpha.value()); auto render_entry = [&](Hy3TabBarEntry& entry) { Vector2D entry_pos = { - (pos.x + (entry.offset.fl() * size.x) + (*padding * 0.5)) * scale, + (pos.x + (entry.offset.value() * size.x) + (*padding * 0.5)) * scale, scaled_pos.y - + ((entry.vertical_pos.fl() * (size.y + *padding) * scale) * (*enter_from_top ? -1 : 1) + + ((entry.vertical_pos.value() * (size.y + *padding) * scale) * (*enter_from_top ? -1 : 1) ), }; - Vector2D entry_size = {((entry.width.fl() * size.x) - *padding) * scale, scaled_size.y}; + Vector2D entry_size = {((entry.width.value() * size.x) - *padding) * scale, scaled_size.y}; if (entry_size.x < 0 || entry_size.y < 0 || fade_opacity == 0.0) return; CBox box = { @@ -627,16 +627,16 @@ void Hy3TabGroup::renderTabBar() { }; entry.prepareTexture(scale, box); - g_pHyprOpenGL->renderTexture(entry.texture, &box, fade_opacity * entry.fade_opacity.fl()); + g_pHyprOpenGL->renderTexture(entry.texture, &box, fade_opacity * entry.fade_opacity.value()); }; for (auto& entry: this->bar.entries) { - if (entry.focused.goalf() == 1.0) continue; + if (entry.focused.goal() == 1.0) continue; render_entry(entry); } for (auto& entry: this->bar.entries) { - if (entry.focused.goalf() == 0.0) continue; + if (entry.focused.goal() == 0.0) continue; render_entry(entry); } @@ -677,5 +677,5 @@ void findOverlappingWindows(Hy3Node& node, float height, std::vector& void Hy3TabGroup::updateStencilWindows(Hy3Node& group) { this->stencil_windows.clear(); - findOverlappingWindows(group, this->size.goalv().y, this->stencil_windows); + findOverlappingWindows(group, this->size.goal().y, this->stencil_windows); } diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 6cf92c7..77f7874 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -16,12 +16,12 @@ struct Hy3TabBarEntry { std::string window_title; bool destroying = false; CTexture texture; - CAnimatedVariable focused; - CAnimatedVariable urgent; - CAnimatedVariable offset; // 0.0-1.0 of total bar - CAnimatedVariable width; // 0.0-1.0 of total bar - CAnimatedVariable vertical_pos; // 0.0-1.0, user specified direction - CAnimatedVariable fade_opacity; // 0.0-1.0 + CAnimatedVariable focused; + CAnimatedVariable urgent; + CAnimatedVariable offset; // 0.0-1.0 of total bar + CAnimatedVariable width; // 0.0-1.0 of total bar + CAnimatedVariable vertical_pos; // 0.0-1.0, user specified direction + CAnimatedVariable fade_opacity; // 0.0-1.0 Hy3TabBar& tab_bar; Hy3Node& node; // only used for comparioson. do not deref. @@ -62,7 +62,7 @@ public: bool destroy = false; bool dirty = true; bool damaged = true; - CAnimatedVariable fade_opacity; + CAnimatedVariable fade_opacity; Hy3TabBar(); void beginDestroy(); @@ -89,8 +89,8 @@ public: int workspace_id = -1; bool hidden = false; Hy3TabBar bar; - CAnimatedVariable pos; - CAnimatedVariable size; + CAnimatedVariable pos; + CAnimatedVariable size; // initialize a group with the given node. UB if node is not a group. Hy3TabGroup(Hy3Node&); From c192ea301777962ab7f5c2646f8fe4e1e32ea821 Mon Sep 17 00:00:00 2001 From: Santos <34815293+sant0s12@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:18:49 +0100 Subject: [PATCH 6/7] Force reload config after plugin is loaded --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index a7f69a9..7b06f1b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,6 +70,8 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { registerDispatchers(); + HyprlandAPI::reloadConfig(); + return {"hy3", "i3 like layout for hyprland", "outfoxxed", "0.1"}; } From 890443f504419ec12c7591f7ef17cbea9d34c9ca Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 6 Mar 2024 03:17:08 -0800 Subject: [PATCH 7/7] Remove patches for tabs with hyprland#4992 --- flake.lock | 28 ++++++++++++++++------------ src/TabGroup.cpp | 8 -------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index cbaba3e..6695ff8 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1709339717, - "narHash": "sha256-VXh6tiY1+Tmaz+dgUNE5IpWaFq4wbf/iCTHclGm33vA=", + "lastModified": 1709720053, + "narHash": "sha256-hR0RSeqFOXCggqbGhkFZT3ZAbGc2cAoeeyXU3V5J4hU=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "b2c34404777ea0850f90f4c38f64484f03599d14", + "rev": "d6f1b151b2fe85ffbb131cbdd05acefc6a357e81", "type": "github" }, "original": { @@ -53,14 +53,18 @@ "nixpkgs": [ "hyprland", "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" ] }, "locked": { - "lastModified": 1708005943, - "narHash": "sha256-9TT3xk++LI5/SPYgjYX34xZ4ebR93c1uerIq+SE/ues=", + "lastModified": 1708787654, + "narHash": "sha256-7ACgM3ZuAhPqurXHUvR2nWMRcnmzGGPjLK6q4DSTelI=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "aeb3e012adc7b3235335c540b214b82267c2b983", + "rev": "0fce791ba2334aca183f2ed42399518947550d0d", "type": "github" }, "original": { @@ -71,11 +75,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1709479366, - "narHash": "sha256-n6F0n8UV6lnTZbYPl1A9q1BS0p4hduAv1mGAP17CVd0=", + "lastModified": 1708807242, + "narHash": "sha256-sRTRkhMD4delO/hPxxi+XwLqPn8BuUq6nnj4JqLwOu0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b8697e57f10292a6165a20f03d2f42920dfaf973", + "rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a", "type": "github" }, "original": { @@ -144,11 +148,11 @@ ] }, "locked": { - "lastModified": 1706521509, - "narHash": "sha256-AInZ50acOJ3wzUwGzNr1TmxGTMx+8j6oSTzz4E7Vbp8=", + "lastModified": 1708696469, + "narHash": "sha256-shh5wmpeYy3MmsBfkm4f76yPsBDGk6OLYRVG+ARy2F0=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "c06fd88b3da492b8f9067be021b9184f7012b5a8", + "rev": "1b713911c2f12b96c2574474686e4027ac4bf826", "type": "github" }, "original": { diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index c79d089..d400f04 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -53,11 +53,6 @@ Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_b AVARDAMAGE_NONE ); - // !!! Can be removed after hyprland#4992 - this->offset = -1.0f; - this->width = -1.0f; - this->vertical_pos = 1.0f; - this->focused.registerVar(); this->urgent.registerVar(); this->offset.registerVar(); @@ -283,9 +278,6 @@ Hy3TabBar::Hy3TabBar() { AVARDAMAGE_NONE ); - // !!! Can be removed after hyprland#4992 - this->fade_opacity = 1.0f; - this->fade_opacity.registerVar(); this->fade_opacity.setUpdateCallback([this](void*) { this->dirty = true; }); }