diff --git a/flake.lock b/flake.lock index d4e49b3..966481a 100644 --- a/flake.lock +++ b/flake.lock @@ -8,11 +8,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1687865038, - "narHash": "sha256-zFTxFNXmXc2XOriWtNzuznEICcSBnIbRVVR/M5w/Y40=", + "lastModified": 1689264334, + "narHash": "sha256-CJv3Qi00et2dFBWXTx9ysYdYauFtxxs+3pXr0gq/UX0=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "d83296c7a9029eccc04544ddf0a8387d8104b882", + "rev": "f8def68e7e761e33dd51c197ac89194a51fcb60f", "type": "github" }, "original": { @@ -44,11 +44,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1687502512, - "narHash": "sha256-dBL/01TayOSZYxtY4cMXuNCBk8UMLoqRZA+94xiFpJA=", + "lastModified": 1688500189, + "narHash": "sha256-djYYiY4lzJOlXOnTHytH6BUugrxHDZjuGxTSrU4gt4M=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3ae20aa58a6c0d1ca95c9b11f59a2d12eebc511f", + "rev": "78419edadf0fabbe5618643bd850b2f2198ed060", "type": "github" }, "original": { diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 6497d27..5b06766 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -258,42 +258,22 @@ void Hy3Layout::recalculateWindow(CWindow* window) { node->recalcSizePosRecursive(); } -void Hy3Layout::onBeginDragWindow() { - this->drag_flags.started = false; - IHyprLayout::onBeginDragWindow(); -} - -void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { +void Hy3Layout::resizeActiveWindow(const Vector2D& delta, eRectCorner corner, CWindow* pWindow) { auto window = pWindow ? pWindow : g_pCompositor->m_pLastWindow; if (!g_pCompositor->windowValidMapped(window)) return; auto* node = this->getNodeFromWindow(window); if (node == nullptr) return; - if (!this->drag_flags.started) { - if (g_pInputManager->currentlyDraggedWindow == window) { - auto mouse = g_pInputManager->getMouseCoordsInternal(); - auto mouse_offset = mouse - window->m_vPosition; + bool drag_x; + bool drag_y; - this->drag_flags = { - .started = true, - .xExtent = mouse_offset.x > window->m_vSize.x / 2, - .yExtent = mouse_offset.y > window->m_vSize.y / 2, - }; - - Debug::log( - LOG, - "Positive offsets - x: %d, y: %d", - this->drag_flags.xExtent, - this->drag_flags.yExtent - ); - } else { - this->drag_flags = { - .started = false, - .xExtent = delta.x > 0, - .yExtent = delta.y > 0, - }; - } + if (corner == CORNER_NONE) { + drag_x = delta.x > 0; + drag_y = delta.y > 0; + } else { + drag_x = corner == CORNER_TOPRIGHT || corner == CORNER_BOTTOMRIGHT; + drag_y = corner == CORNER_BOTTOMLEFT || corner == CORNER_BOTTOMRIGHT; } const auto animate @@ -330,15 +310,15 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { // treat tabbed layouts as if they dont exist during resizing goto cont; case Hy3GroupLayout::SplitH: - if ((this->drag_flags.xExtent && group.children.back() == inner_node) - || (!this->drag_flags.xExtent && group.children.front() == inner_node)) + if ((drag_x && group.children.back() == inner_node) + || (!drag_x && group.children.front() == inner_node)) { goto cont; } break; case Hy3GroupLayout::SplitV: - if ((this->drag_flags.yExtent && group.children.back() == inner_node) - || (!this->drag_flags.yExtent && group.children.front() == inner_node)) + if ((drag_y && group.children.back() == inner_node) + || (!drag_y && group.children.front() == inner_node)) { goto cont; } @@ -368,15 +348,15 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { // treat tabbed layouts as if they dont exist during resizing goto cont2; case Hy3GroupLayout::SplitH: - if ((this->drag_flags.xExtent && group.children.back() == outer_node) - || (!this->drag_flags.xExtent && group.children.front() == outer_node)) + if ((drag_x && group.children.back() == outer_node) + || (!drag_x && group.children.front() == outer_node)) { goto cont2; } break; case Hy3GroupLayout::SplitV: - if ((this->drag_flags.yExtent && group.children.back() == outer_node) - || (!this->drag_flags.yExtent && group.children.front() == outer_node)) + if ((drag_y && group.children.back() == outer_node) + || (!drag_y && group.children.front() == outer_node)) { goto cont2; } @@ -399,7 +379,7 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { auto iter = std::find(inner_group.children.begin(), inner_group.children.end(), inner_node); - if (this->drag_flags.xExtent) { + if (drag_x) { if (inner_node == inner_group.children.back()) break; iter = std::next(iter); } else { @@ -419,7 +399,7 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { auto iter = std::find(inner_group.children.begin(), inner_group.children.end(), inner_node); - if (this->drag_flags.yExtent) { + if (drag_y) { if (inner_node == inner_group.children.back()) break; iter = std::next(iter); } else { @@ -449,7 +429,7 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { auto iter = std::find(outer_group.children.begin(), outer_group.children.end(), outer_node); - if (this->drag_flags.xExtent) { + if (drag_x) { if (outer_node == inner_group.children.back()) break; iter = std::next(iter); } else { @@ -469,7 +449,7 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { auto iter = std::find(outer_group.children.begin(), outer_group.children.end(), outer_node); - if (this->drag_flags.yExtent) { + if (drag_y) { if (outer_node == outer_group.children.back()) break; iter = std::next(iter); } else { diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index d6d4186..d87f945 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -46,8 +46,8 @@ public: virtual bool isWindowTiled(CWindow*); virtual void recalculateMonitor(const int& monitor_id); virtual void recalculateWindow(CWindow*); - virtual void onBeginDragWindow(); - virtual void resizeActiveWindow(const Vector2D& delta, CWindow* pWindow = nullptr); + 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*); @@ -84,12 +84,6 @@ public: std::list tab_groups; private: - struct { - bool started = false; - bool xExtent = false; - bool yExtent = false; - } drag_flags; - Hy3Node* getNodeFromWindow(CWindow*); void applyNodeDataToWindow(Hy3Node*, bool no_animation = false);