mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 10:29:50 +01:00
Window resizing for pseudotiled windows (#2140)
* Window resizing for pseudotiled windows * Use `m_vRealSize` to determine scaled window size
This commit is contained in:
parent
bf27066fd7
commit
849d657595
2 changed files with 58 additions and 6 deletions
|
@ -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)
|
||||||
|
|
|
@ -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,6 +62,13 @@ class CHyprDwindleLayout : public IHyprLayout {
|
||||||
private:
|
private:
|
||||||
std::list<SDwindleNodeData> m_lDwindleNodesData;
|
std::list<SDwindleNodeData> m_lDwindleNodesData;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
bool started = false;
|
||||||
|
bool pseudo = false;
|
||||||
|
bool xExtent = false;
|
||||||
|
bool yExtent = false;
|
||||||
|
} m_PseudoDragFlags;
|
||||||
|
|
||||||
int getNodesOnWorkspace(const int&);
|
int getNodesOnWorkspace(const int&);
|
||||||
void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
|
void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
|
||||||
SDwindleNodeData* getNodeFromWindow(CWindow*);
|
SDwindleNodeData* getNodeFromWindow(CWindow*);
|
||||||
|
|
Loading…
Reference in a new issue