mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 15:05:58 +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;
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue