Window resizing for pseudotiled windows (#2140)

* Window resizing for pseudotiled windows

* Use `m_vRealSize` to determine scaled window size
This commit is contained in:
outfoxxed 2023-04-25 15:53:18 +00:00 committed by GitHub
parent bf27066fd7
commit 849d657595
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 6 deletions

View file

@ -497,6 +497,12 @@ bool CHyprDwindleLayout::isWindowTiled(CWindow* pWindow) {
return getNodeFromWindow(pWindow) != nullptr; 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) { void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow* pWindow) {
const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_pLastWindow; 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 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); 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 // construct allowed movement
Vector2D allowedMovement = pixResize; Vector2D allowedMovement = pixResize;
if (DISPLAYLEFT && DISPLAYRIGHT) if (DISPLAYLEFT && DISPLAYRIGHT)

View file

@ -46,6 +46,7 @@ class CHyprDwindleLayout : public IHyprLayout {
virtual bool isWindowTiled(CWindow*); virtual bool isWindowTiled(CWindow*);
virtual void recalculateMonitor(const int&); virtual void recalculateMonitor(const int&);
virtual void recalculateWindow(CWindow*); virtual void recalculateWindow(CWindow*);
virtual void onBeginDragWindow();
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr); virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool); virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
virtual std::any layoutMessage(SLayoutMessageHeader, std::string); virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
@ -61,13 +62,20 @@ class CHyprDwindleLayout : public IHyprLayout {
private: private:
std::list<SDwindleNodeData> m_lDwindleNodesData; std::list<SDwindleNodeData> m_lDwindleNodesData;
int getNodesOnWorkspace(const int&); struct {
void applyNodeDataToWindow(SDwindleNodeData*, bool force = false); bool started = false;
SDwindleNodeData* getNodeFromWindow(CWindow*); bool pseudo = false;
SDwindleNodeData* getFirstNodeOnWorkspace(const int&); bool xExtent = false;
SDwindleNodeData* getMasterNodeOnWorkspace(const int&); 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; friend struct SDwindleNodeData;
}; };