aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoroutfoxxed <[email protected]>2023-04-25 15:53:18 +0000
committerGitHub <[email protected]>2023-04-25 16:53:18 +0100
commit849d65759546bb453481a4a7b5699c540027a05f (patch)
tree28db817daa1d961b8ee526c22a0609893d6d729a
parentbf27066fd7479ec161b7e52467bca56d1fa65e6d (diff)
downloadHyprland-849d65759546bb453481a4a7b5699c540027a05f.tar.gz
Hyprland-849d65759546bb453481a4a7b5699c540027a05f.zip
Window resizing for pseudotiled windows (#2140)
* Window resizing for pseudotiled windows * Use `m_vRealSize` to determine scaled window size
-rw-r--r--src/layout/DwindleLayout.cpp44
-rw-r--r--src/layout/DwindleLayout.hpp20
2 files changed, 58 insertions, 6 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index b1aad296..2bf91809 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -497,6 +497,12 @@ bool CHyprDwindleLayout::isWindowTiled(CWindow* pWindow) {
return getNodeFromWindow(pWindow) != nullptr;
}
+void CHyprDwindleLayout::onBeginDragWindow() {
+ m_PseudoDragFlags.started = false;
+ m_PseudoDragFlags.pseudo = false;
+ IHyprLayout::onBeginDragWindow();
+}
+
void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow* pWindow) {
const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_pLastWindow;
@@ -521,6 +527,44 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
const bool DISPLAYTOP = STICKS(PWINDOW->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
const bool DISPLAYBOTTOM = STICKS(PWINDOW->m_vPosition.y + PWINDOW->m_vSize.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
+ if (PWINDOW->m_bIsPseudotiled) {
+ if (!m_PseudoDragFlags.started) {
+ m_PseudoDragFlags.started = true;
+
+ const auto pseudoSize = PWINDOW->m_vRealSize.goalv();
+ const auto mouseOffset = g_pInputManager->getMouseCoordsInternal() - (PNODE->position + ((PNODE->size / 2) - (pseudoSize / 2)));
+
+ if (mouseOffset.x > 0 && mouseOffset.x < pseudoSize.x && mouseOffset.y > 0 && mouseOffset.y < pseudoSize.y) {
+ m_PseudoDragFlags.pseudo = true;
+ m_PseudoDragFlags.xExtent = mouseOffset.x > pseudoSize.x / 2;
+ m_PseudoDragFlags.yExtent = mouseOffset.y > pseudoSize.y / 2;
+
+ PWINDOW->m_vPseudoSize = pseudoSize;
+ } else {
+ m_PseudoDragFlags.pseudo = false;
+ }
+ }
+
+ if (m_PseudoDragFlags.pseudo) {
+ if (m_PseudoDragFlags.xExtent)
+ PWINDOW->m_vPseudoSize.x += pixResize.x * 2;
+ else
+ PWINDOW->m_vPseudoSize.x -= pixResize.x * 2;
+ if (m_PseudoDragFlags.yExtent)
+ PWINDOW->m_vPseudoSize.y += pixResize.y * 2;
+ else
+ PWINDOW->m_vPseudoSize.y -= pixResize.y * 2;
+
+ PWINDOW->m_vPseudoSize.x = std::clamp(PWINDOW->m_vPseudoSize.x, 30.0, PNODE->size.x);
+ PWINDOW->m_vPseudoSize.y = std::clamp(PWINDOW->m_vPseudoSize.y, 30.0, PNODE->size.y);
+
+ PWINDOW->m_vLastFloatingSize = PWINDOW->m_vPseudoSize;
+ PNODE->recalcSizePosRecursive(*PANIMATE == 0);
+
+ return;
+ }
+ }
+
// construct allowed movement
Vector2D allowedMovement = pixResize;
if (DISPLAYLEFT && DISPLAYRIGHT)
diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp
index d0142ec7..164596a3 100644
--- a/src/layout/DwindleLayout.hpp
+++ b/src/layout/DwindleLayout.hpp
@@ -46,6 +46,7 @@ class CHyprDwindleLayout : public IHyprLayout {
virtual bool isWindowTiled(CWindow*);
virtual void recalculateMonitor(const int&);
virtual void recalculateWindow(CWindow*);
+ virtual void onBeginDragWindow();
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
@@ -61,13 +62,20 @@ class CHyprDwindleLayout : public IHyprLayout {
private:
std::list<SDwindleNodeData> m_lDwindleNodesData;
- int getNodesOnWorkspace(const int&);
- void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
- SDwindleNodeData* getNodeFromWindow(CWindow*);
- SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
- SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
+ struct {
+ bool started = false;
+ bool pseudo = false;
+ bool xExtent = false;
+ bool yExtent = false;
+ } m_PseudoDragFlags;
- void toggleSplit(CWindow*);
+ int getNodesOnWorkspace(const int&);
+ void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
+ SDwindleNodeData* getNodeFromWindow(CWindow*);
+ SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
+ SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
+
+ void toggleSplit(CWindow*);
friend struct SDwindleNodeData;
};