mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-05-19 08:30:22 -07:00
layouts: refactor class member vars (#10228)
This commit is contained in:
parent
ce4766772d
commit
615e0dae46
@ -45,7 +45,7 @@ void SDwindleNodeData::recalcSizePosRecursive(bool force, bool horizontalOverrid
|
||||
|
||||
int CHyprDwindleLayout::getNodesOnWorkspace(const WORKSPACEID& id) {
|
||||
int no = 0;
|
||||
for (auto const& n : m_lDwindleNodesData) {
|
||||
for (auto const& n : m_dwindleNodesData) {
|
||||
if (n.workspaceID == id && n.valid)
|
||||
++no;
|
||||
}
|
||||
@ -53,7 +53,7 @@ int CHyprDwindleLayout::getNodesOnWorkspace(const WORKSPACEID& id) {
|
||||
}
|
||||
|
||||
SDwindleNodeData* CHyprDwindleLayout::getFirstNodeOnWorkspace(const WORKSPACEID& id) {
|
||||
for (auto& n : m_lDwindleNodesData) {
|
||||
for (auto& n : m_dwindleNodesData) {
|
||||
if (n.workspaceID == id && validMapped(n.pWindow))
|
||||
return &n;
|
||||
}
|
||||
@ -63,7 +63,7 @@ SDwindleNodeData* CHyprDwindleLayout::getFirstNodeOnWorkspace(const WORKSPACEID&
|
||||
SDwindleNodeData* CHyprDwindleLayout::getClosestNodeOnWorkspace(const WORKSPACEID& id, const Vector2D& point) {
|
||||
SDwindleNodeData* res = nullptr;
|
||||
double distClosest = -1;
|
||||
for (auto& n : m_lDwindleNodesData) {
|
||||
for (auto& n : m_dwindleNodesData) {
|
||||
if (n.workspaceID == id && validMapped(n.pWindow)) {
|
||||
auto distAnother = vecToRectDistanceSquared(point, n.box.pos(), n.box.pos() + n.box.size());
|
||||
if (!res || distAnother < distClosest) {
|
||||
@ -76,7 +76,7 @@ SDwindleNodeData* CHyprDwindleLayout::getClosestNodeOnWorkspace(const WORKSPACEI
|
||||
}
|
||||
|
||||
SDwindleNodeData* CHyprDwindleLayout::getNodeFromWindow(PHLWINDOW pWindow) {
|
||||
for (auto& n : m_lDwindleNodesData) {
|
||||
for (auto& n : m_dwindleNodesData) {
|
||||
if (n.pWindow.lock() == pWindow && !n.isNode)
|
||||
return &n;
|
||||
}
|
||||
@ -85,7 +85,7 @@ SDwindleNodeData* CHyprDwindleLayout::getNodeFromWindow(PHLWINDOW pWindow) {
|
||||
}
|
||||
|
||||
SDwindleNodeData* CHyprDwindleLayout::getMasterNodeOnWorkspace(const WORKSPACEID& id) {
|
||||
for (auto& n : m_lDwindleNodesData) {
|
||||
for (auto& n : m_dwindleNodesData) {
|
||||
if (!n.pParent && n.workspaceID == id)
|
||||
return &n;
|
||||
}
|
||||
@ -223,16 +223,16 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
|
||||
if (pWindow->m_isFloating)
|
||||
return;
|
||||
|
||||
m_lDwindleNodesData.emplace_back();
|
||||
const auto PNODE = &m_lDwindleNodesData.back();
|
||||
m_dwindleNodesData.emplace_back();
|
||||
const auto PNODE = &m_dwindleNodesData.back();
|
||||
|
||||
const auto PMONITOR = pWindow->m_monitor.lock();
|
||||
|
||||
static auto PUSEACTIVE = CConfigValue<Hyprlang::INT>("dwindle:use_active_for_splits");
|
||||
static auto PDEFAULTSPLIT = CConfigValue<Hyprlang::FLOAT>("dwindle:default_split_ratio");
|
||||
|
||||
if (direction != DIRECTION_DEFAULT && overrideDirection == DIRECTION_DEFAULT)
|
||||
overrideDirection = direction;
|
||||
if (direction != DIRECTION_DEFAULT && m_overrideDirection == DIRECTION_DEFAULT)
|
||||
m_overrideDirection = direction;
|
||||
|
||||
// Populate the node with our window's data
|
||||
PNODE->workspaceID = pWindow->workspaceID();
|
||||
@ -242,7 +242,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
|
||||
|
||||
SDwindleNodeData* OPENINGON;
|
||||
|
||||
const auto MOUSECOORDS = m_vOverrideFocalPoint.value_or(g_pInputManager->getMouseCoordsInternal());
|
||||
const auto MOUSECOORDS = m_overrideFocalPoint.value_or(g_pInputManager->getMouseCoordsInternal());
|
||||
const auto MONFROMCURSOR = g_pCompositor->getMonitorFromVector(MOUSECOORDS);
|
||||
|
||||
if (PMONITOR->m_id == MONFROMCURSOR->m_id &&
|
||||
@ -278,14 +278,14 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
|
||||
if (const auto MAXSIZE = pWindow->requestedMaxSize(); MAXSIZE.x < PREDSIZEMAX.x || MAXSIZE.y < PREDSIZEMAX.y) {
|
||||
// we can't continue. make it floating.
|
||||
pWindow->m_isFloating = true;
|
||||
m_lDwindleNodesData.remove(*PNODE);
|
||||
m_dwindleNodesData.remove(*PNODE);
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow);
|
||||
return;
|
||||
}
|
||||
|
||||
// last fail-safe to avoid duplicate fullscreens
|
||||
if ((!OPENINGON || OPENINGON->pWindow.lock() == pWindow) && getNodesOnWorkspace(PNODE->workspaceID) > 1) {
|
||||
for (auto& node : m_lDwindleNodesData) {
|
||||
for (auto& node : m_dwindleNodesData) {
|
||||
if (node.workspaceID == PNODE->workspaceID && node.pWindow.lock() && node.pWindow.lock() != pWindow) {
|
||||
OPENINGON = &node;
|
||||
break;
|
||||
@ -304,8 +304,8 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
|
||||
|
||||
// get the node under our cursor
|
||||
|
||||
m_lDwindleNodesData.emplace_back();
|
||||
const auto NEWPARENT = &m_lDwindleNodesData.back();
|
||||
m_dwindleNodesData.emplace_back();
|
||||
const auto NEWPARENT = &m_dwindleNodesData.back();
|
||||
|
||||
// make the parent have the OPENINGON's stats
|
||||
NEWPARENT->box = OPENINGON->box;
|
||||
@ -328,16 +328,16 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
|
||||
bool verticalOverride = false;
|
||||
|
||||
// let user select position -> top, right, bottom, left
|
||||
if (overrideDirection != DIRECTION_DEFAULT) {
|
||||
if (m_overrideDirection != DIRECTION_DEFAULT) {
|
||||
|
||||
// this is horizontal
|
||||
if (overrideDirection % 2 == 0)
|
||||
if (m_overrideDirection % 2 == 0)
|
||||
verticalOverride = true;
|
||||
else
|
||||
horizontalOverride = true;
|
||||
|
||||
// 0 -> top and left | 1,2 -> right and bottom
|
||||
if (overrideDirection % 3 == 0) {
|
||||
if (m_overrideDirection % 3 == 0) {
|
||||
NEWPARENT->children[1] = OPENINGON;
|
||||
NEWPARENT->children[0] = PNODE;
|
||||
} else {
|
||||
@ -347,7 +347,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
|
||||
|
||||
// whether or not the override persists after opening one window
|
||||
if (*PERMANENTDIRECTIONOVERRIDE == 0)
|
||||
overrideDirection = DIRECTION_DEFAULT;
|
||||
m_overrideDirection = DIRECTION_DEFAULT;
|
||||
} else if (*PSMARTSPLIT == 1) {
|
||||
const auto PARENT_CENTER = NEWPARENT->box.pos() + NEWPARENT->box.size() / 2;
|
||||
const auto PARENT_PROPORTIONS = NEWPARENT->box.h / NEWPARENT->box.w;
|
||||
@ -455,7 +455,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
|
||||
|
||||
if (!PPARENT) {
|
||||
Debug::log(LOG, "Removing last node (dwindle)");
|
||||
m_lDwindleNodesData.remove(*PNODE);
|
||||
m_dwindleNodesData.remove(*PNODE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -480,8 +480,8 @@ void CHyprDwindleLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
|
||||
else
|
||||
PSIBLING->recalcSizePosRecursive();
|
||||
|
||||
m_lDwindleNodesData.remove(*PPARENT);
|
||||
m_lDwindleNodesData.remove(*PNODE);
|
||||
m_dwindleNodesData.remove(*PPARENT);
|
||||
m_dwindleNodesData.remove(*PNODE);
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::recalculateMonitor(const MONITORID& monid) {
|
||||
@ -540,8 +540,8 @@ bool CHyprDwindleLayout::isWindowTiled(PHLWINDOW pWindow) {
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::onBeginDragWindow() {
|
||||
m_PseudoDragFlags.started = false;
|
||||
m_PseudoDragFlags.pseudo = false;
|
||||
m_pseudoDragFlags.started = false;
|
||||
m_pseudoDragFlags.pseudo = false;
|
||||
IHyprLayout::onBeginDragWindow();
|
||||
}
|
||||
|
||||
@ -573,29 +573,29 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
|
||||
const bool DISPLAYBOTTOM = STICKS(PWINDOW->m_position.y + PWINDOW->m_size.y, PMONITOR->m_position.y + PMONITOR->m_size.y - PMONITOR->m_reservedBottomRight.y);
|
||||
|
||||
if (PWINDOW->m_isPseudotiled) {
|
||||
if (!m_PseudoDragFlags.started) {
|
||||
m_PseudoDragFlags.started = true;
|
||||
if (!m_pseudoDragFlags.started) {
|
||||
m_pseudoDragFlags.started = true;
|
||||
|
||||
const auto pseudoSize = PWINDOW->m_realSize->goal();
|
||||
const auto mouseOffset = g_pInputManager->getMouseCoordsInternal() - (PNODE->box.pos() + ((PNODE->box.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;
|
||||
m_pseudoDragFlags.pseudo = true;
|
||||
m_pseudoDragFlags.xExtent = mouseOffset.x > pseudoSize.x / 2;
|
||||
m_pseudoDragFlags.yExtent = mouseOffset.y > pseudoSize.y / 2;
|
||||
|
||||
PWINDOW->m_pseudoSize = pseudoSize;
|
||||
} else {
|
||||
m_PseudoDragFlags.pseudo = false;
|
||||
m_pseudoDragFlags.pseudo = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_PseudoDragFlags.pseudo) {
|
||||
if (m_PseudoDragFlags.xExtent)
|
||||
if (m_pseudoDragFlags.pseudo) {
|
||||
if (m_pseudoDragFlags.xExtent)
|
||||
PWINDOW->m_pseudoSize.x += pixResize.x * 2;
|
||||
else
|
||||
PWINDOW->m_pseudoSize.x -= pixResize.x * 2;
|
||||
if (m_PseudoDragFlags.yExtent)
|
||||
if (m_pseudoDragFlags.yExtent)
|
||||
PWINDOW->m_pseudoSize.y += pixResize.y * 2;
|
||||
else
|
||||
PWINDOW->m_pseudoSize.y -= pixResize.y * 2;
|
||||
@ -837,7 +837,7 @@ void CHyprDwindleLayout::moveWindowTo(PHLWINDOW pWindow, const std::string& dir,
|
||||
|
||||
onWindowRemovedTiling(pWindow);
|
||||
|
||||
m_vOverrideFocalPoint = focalPoint;
|
||||
m_overrideFocalPoint = focalPoint;
|
||||
|
||||
const auto PMONITORFOCAL = g_pCompositor->getMonitorFromVector(focalPoint);
|
||||
|
||||
@ -857,7 +857,7 @@ void CHyprDwindleLayout::moveWindowTo(PHLWINDOW pWindow, const std::string& dir,
|
||||
|
||||
onWindowCreatedTiling(pWindow);
|
||||
|
||||
m_vOverrideFocalPoint.reset();
|
||||
m_overrideFocalPoint.reset();
|
||||
|
||||
// restore focus to the previous position
|
||||
if (silent) {
|
||||
@ -957,26 +957,26 @@ std::any CHyprDwindleLayout::layoutMessage(SLayoutMessageHeader header, std::str
|
||||
switch (direction.front()) {
|
||||
case 'u':
|
||||
case 't': {
|
||||
overrideDirection = DIRECTION_UP;
|
||||
m_overrideDirection = DIRECTION_UP;
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
case 'b': {
|
||||
overrideDirection = DIRECTION_DOWN;
|
||||
m_overrideDirection = DIRECTION_DOWN;
|
||||
break;
|
||||
}
|
||||
case 'r': {
|
||||
overrideDirection = DIRECTION_RIGHT;
|
||||
m_overrideDirection = DIRECTION_RIGHT;
|
||||
break;
|
||||
}
|
||||
case 'l': {
|
||||
overrideDirection = DIRECTION_LEFT;
|
||||
m_overrideDirection = DIRECTION_LEFT;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// any other character resets the focus direction
|
||||
// needed for the persistent mode
|
||||
overrideDirection = DIRECTION_DEFAULT;
|
||||
m_overrideDirection = DIRECTION_DEFAULT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1076,7 +1076,7 @@ void CHyprDwindleLayout::onEnable() {
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::onDisable() {
|
||||
m_lDwindleNodesData.clear();
|
||||
m_dwindleNodesData.clear();
|
||||
}
|
||||
|
||||
Vector2D CHyprDwindleLayout::predictSizeForNewWindowTiled() {
|
||||
|
@ -65,16 +65,16 @@ class CHyprDwindleLayout : public IHyprLayout {
|
||||
virtual void onDisable();
|
||||
|
||||
private:
|
||||
std::list<SDwindleNodeData> m_lDwindleNodesData;
|
||||
std::list<SDwindleNodeData> m_dwindleNodesData;
|
||||
|
||||
struct {
|
||||
bool started = false;
|
||||
bool pseudo = false;
|
||||
bool xExtent = false;
|
||||
bool yExtent = false;
|
||||
} m_PseudoDragFlags;
|
||||
} m_pseudoDragFlags;
|
||||
|
||||
std::optional<Vector2D> m_vOverrideFocalPoint; // for onWindowCreatedTiling.
|
||||
std::optional<Vector2D> m_overrideFocalPoint; // for onWindowCreatedTiling.
|
||||
|
||||
int getNodesOnWorkspace(const WORKSPACEID&);
|
||||
void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
|
||||
@ -88,7 +88,7 @@ class CHyprDwindleLayout : public IHyprLayout {
|
||||
void swapSplit(PHLWINDOW);
|
||||
void moveToRoot(PHLWINDOW, bool stable = true);
|
||||
|
||||
eDirection overrideDirection = DIRECTION_DEFAULT;
|
||||
eDirection m_overrideDirection = DIRECTION_DEFAULT;
|
||||
|
||||
friend struct SDwindleNodeData;
|
||||
};
|
||||
|
@ -70,8 +70,8 @@ void IHyprLayout::onWindowRemoved(PHLWINDOW pWindow) {
|
||||
std::swap(PWINDOWPREV->m_groupData.pNextWindow->m_groupData.locked, pWindow->m_groupData.locked);
|
||||
}
|
||||
|
||||
if (pWindow == m_pLastTiledWindow)
|
||||
m_pLastTiledWindow.reset();
|
||||
if (pWindow == m_lastTiledWindow)
|
||||
m_lastTiledWindow.reset();
|
||||
|
||||
pWindow->setHidden(false);
|
||||
|
||||
@ -89,8 +89,8 @@ void IHyprLayout::onWindowRemoved(PHLWINDOW pWindow) {
|
||||
onWindowRemovedTiling(pWindow);
|
||||
}
|
||||
|
||||
if (pWindow == m_pLastTiledWindow)
|
||||
m_pLastTiledWindow.reset();
|
||||
if (pWindow == m_lastTiledWindow)
|
||||
m_lastTiledWindow.reset();
|
||||
}
|
||||
|
||||
void IHyprLayout::onWindowRemovedFloating(PHLWINDOW pWindow) {
|
||||
@ -232,8 +232,8 @@ void IHyprLayout::onBeginDragWindow() {
|
||||
const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow.lock();
|
||||
static auto PDRAGTHRESHOLD = CConfigValue<Hyprlang::INT>("binds:drag_threshold");
|
||||
|
||||
m_iMouseMoveEventCount = 1;
|
||||
m_vBeginDragSizeXY = Vector2D();
|
||||
m_mouseMoveEventCount = 1;
|
||||
m_beginDragSizeXY = Vector2D();
|
||||
|
||||
// Window will be floating. Let's check if it's valid. It should be, but I don't like crashing.
|
||||
if (!validMapped(DRAGGINGWINDOW)) {
|
||||
@ -253,36 +253,36 @@ void IHyprLayout::onBeginDragWindow() {
|
||||
if (*RESIZECORNER != 0 && *RESIZECORNER <= 4 && DRAGGINGWINDOW->m_isFloating) {
|
||||
switch (*RESIZECORNER) {
|
||||
case 1:
|
||||
m_eGrabbedCorner = CORNER_TOPLEFT;
|
||||
m_grabbedCorner = CORNER_TOPLEFT;
|
||||
g_pInputManager->setCursorImageUntilUnset("nw-resize");
|
||||
break;
|
||||
case 2:
|
||||
m_eGrabbedCorner = CORNER_TOPRIGHT;
|
||||
m_grabbedCorner = CORNER_TOPRIGHT;
|
||||
g_pInputManager->setCursorImageUntilUnset("ne-resize");
|
||||
break;
|
||||
case 3:
|
||||
m_eGrabbedCorner = CORNER_BOTTOMRIGHT;
|
||||
m_grabbedCorner = CORNER_BOTTOMRIGHT;
|
||||
g_pInputManager->setCursorImageUntilUnset("se-resize");
|
||||
break;
|
||||
case 4:
|
||||
m_eGrabbedCorner = CORNER_BOTTOMLEFT;
|
||||
m_grabbedCorner = CORNER_BOTTOMLEFT;
|
||||
g_pInputManager->setCursorImageUntilUnset("sw-resize");
|
||||
break;
|
||||
}
|
||||
} else if (m_vBeginDragXY.x < m_vBeginDragPositionXY.x + m_vBeginDragSizeXY.x / 2.0) {
|
||||
if (m_vBeginDragXY.y < m_vBeginDragPositionXY.y + m_vBeginDragSizeXY.y / 2.0) {
|
||||
m_eGrabbedCorner = CORNER_TOPLEFT;
|
||||
} else if (m_beginDragXY.x < m_beginDragPositionXY.x + m_beginDragSizeXY.x / 2.0) {
|
||||
if (m_beginDragXY.y < m_beginDragPositionXY.y + m_beginDragSizeXY.y / 2.0) {
|
||||
m_grabbedCorner = CORNER_TOPLEFT;
|
||||
g_pInputManager->setCursorImageUntilUnset("nw-resize");
|
||||
} else {
|
||||
m_eGrabbedCorner = CORNER_BOTTOMLEFT;
|
||||
m_grabbedCorner = CORNER_BOTTOMLEFT;
|
||||
g_pInputManager->setCursorImageUntilUnset("sw-resize");
|
||||
}
|
||||
} else {
|
||||
if (m_vBeginDragXY.y < m_vBeginDragPositionXY.y + m_vBeginDragSizeXY.y / 2.0) {
|
||||
m_eGrabbedCorner = CORNER_TOPRIGHT;
|
||||
if (m_beginDragXY.y < m_beginDragPositionXY.y + m_beginDragSizeXY.y / 2.0) {
|
||||
m_grabbedCorner = CORNER_TOPRIGHT;
|
||||
g_pInputManager->setCursorImageUntilUnset("ne-resize");
|
||||
} else {
|
||||
m_eGrabbedCorner = CORNER_BOTTOMRIGHT;
|
||||
m_grabbedCorner = CORNER_BOTTOMRIGHT;
|
||||
g_pInputManager->setCursorImageUntilUnset("se-resize");
|
||||
}
|
||||
}
|
||||
@ -301,7 +301,7 @@ void IHyprLayout::onBeginDragWindow() {
|
||||
void IHyprLayout::onEndDragWindow() {
|
||||
const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow.lock();
|
||||
|
||||
m_iMouseMoveEventCount = 1;
|
||||
m_mouseMoveEventCount = 1;
|
||||
|
||||
if (!validMapped(DRAGGINGWINDOW)) {
|
||||
if (DRAGGINGWINDOW) {
|
||||
@ -340,7 +340,7 @@ void IHyprLayout::onEndDragWindow() {
|
||||
}
|
||||
|
||||
DRAGGINGWINDOW->m_isFloating = pWindow->m_isFloating; // match the floating state of the window
|
||||
DRAGGINGWINDOW->m_lastFloatingSize = m_vDraggingWindowOriginalFloatSize;
|
||||
DRAGGINGWINDOW->m_lastFloatingSize = m_draggingWindowOriginalFloatSize;
|
||||
DRAGGINGWINDOW->m_draggingTiled = false;
|
||||
|
||||
static auto USECURRPOS = CConfigValue<Hyprlang::INT>("group:insert_after_current");
|
||||
@ -359,7 +359,7 @@ void IHyprLayout::onEndDragWindow() {
|
||||
DRAGGINGWINDOW->m_isFloating = false;
|
||||
g_pInputManager->refocus();
|
||||
changeWindowFloatingMode(DRAGGINGWINDOW);
|
||||
DRAGGINGWINDOW->m_lastFloatingSize = m_vDraggingWindowOriginalFloatSize;
|
||||
DRAGGINGWINDOW->m_lastFloatingSize = m_draggingWindowOriginalFloatSize;
|
||||
}
|
||||
|
||||
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
|
||||
@ -525,14 +525,14 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
|
||||
static auto PDRAGTHRESHOLD = CConfigValue<Hyprlang::INT>("binds:drag_threshold");
|
||||
|
||||
// Window invalid or drag begin size 0,0 meaning we rejected it.
|
||||
if ((!validMapped(DRAGGINGWINDOW) || m_vBeginDragSizeXY == Vector2D())) {
|
||||
if ((!validMapped(DRAGGINGWINDOW) || m_beginDragSizeXY == Vector2D())) {
|
||||
g_pKeybindManager->changeMouseBindMode(MBIND_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
// Yoink dragged window here instead if using drag_threshold and it has been reached
|
||||
if (*PDRAGTHRESHOLD > 0 && !g_pInputManager->m_bDragThresholdReached) {
|
||||
if ((m_vBeginDragXY.distanceSq(mousePos) <= std::pow(*PDRAGTHRESHOLD, 2) && m_vBeginDragXY == m_vLastDragXY))
|
||||
if ((m_beginDragXY.distanceSq(mousePos) <= std::pow(*PDRAGTHRESHOLD, 2) && m_beginDragXY == m_lastDragXY))
|
||||
return;
|
||||
g_pInputManager->m_bDragThresholdReached = true;
|
||||
if (updateDragWindow())
|
||||
@ -543,8 +543,8 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
|
||||
|
||||
const auto SPECIAL = DRAGGINGWINDOW->onSpecialWorkspace();
|
||||
|
||||
const auto DELTA = Vector2D(mousePos.x - m_vBeginDragXY.x, mousePos.y - m_vBeginDragXY.y);
|
||||
const auto TICKDELTA = Vector2D(mousePos.x - m_vLastDragXY.x, mousePos.y - m_vLastDragXY.y);
|
||||
const auto DELTA = Vector2D(mousePos.x - m_beginDragXY.x, mousePos.y - m_beginDragXY.y);
|
||||
const auto TICKDELTA = Vector2D(mousePos.x - m_lastDragXY.x, mousePos.y - m_lastDragXY.y);
|
||||
|
||||
static auto PANIMATEMOUSE = CConfigValue<Hyprlang::INT>("misc:animate_mouse_windowdragging");
|
||||
static auto PANIMATE = CConfigValue<Hyprlang::INT>("misc:animate_manual_resizes");
|
||||
@ -559,15 +559,15 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
|
||||
|
||||
MSTIMER = std::chrono::high_resolution_clock::now();
|
||||
|
||||
if (m_iMouseMoveEventCount == 1)
|
||||
if (m_mouseMoveEventCount == 1)
|
||||
totalMs = 0;
|
||||
|
||||
if (MSMONITOR > 16.0) {
|
||||
totalMs += MSDELTA < MSMONITOR ? MSDELTA : std::round(totalMs * 1.0 / m_iMouseMoveEventCount);
|
||||
m_iMouseMoveEventCount += 1;
|
||||
totalMs += MSDELTA < MSMONITOR ? MSDELTA : std::round(totalMs * 1.0 / m_mouseMoveEventCount);
|
||||
m_mouseMoveEventCount += 1;
|
||||
|
||||
// check if time-window is enough to skip update on 60hz monitor
|
||||
canSkipUpdate = std::clamp(MSMONITOR - TIMERDELTA, 0.0, MSMONITOR) > totalMs * 1.0 / m_iMouseMoveEventCount;
|
||||
canSkipUpdate = std::clamp(MSMONITOR - TIMERDELTA, 0.0, MSMONITOR) > totalMs * 1.0 / m_mouseMoveEventCount;
|
||||
}
|
||||
|
||||
if ((abs(TICKDELTA.x) < 1.f && abs(TICKDELTA.y) < 1.f) || (TIMERDELTA < MSMONITOR && canSkipUpdate && (g_pInputManager->dragMode != MBIND_MOVE || *PANIMATEMOUSE)))
|
||||
@ -575,17 +575,17 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
|
||||
|
||||
TIMER = std::chrono::high_resolution_clock::now();
|
||||
|
||||
m_vLastDragXY = mousePos;
|
||||
m_lastDragXY = mousePos;
|
||||
|
||||
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
|
||||
|
||||
if (g_pInputManager->dragMode == MBIND_MOVE) {
|
||||
|
||||
Vector2D newPos = m_vBeginDragPositionXY + DELTA;
|
||||
Vector2D newPos = m_beginDragPositionXY + DELTA;
|
||||
Vector2D newSize = DRAGGINGWINDOW->m_realSize->goal();
|
||||
|
||||
if (*SNAPENABLED && !DRAGGINGWINDOW->m_draggingTiled)
|
||||
performSnap(newPos, newSize, DRAGGINGWINDOW, MBIND_MOVE, -1, m_vBeginDragSizeXY);
|
||||
performSnap(newPos, newSize, DRAGGINGWINDOW, MBIND_MOVE, -1, m_beginDragSizeXY);
|
||||
|
||||
CBox wb = {newPos, newSize};
|
||||
wb.round();
|
||||
@ -609,25 +609,25 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
|
||||
else
|
||||
MAXSIZE = DRAGGINGWINDOW->requestedMaxSize().clamp({}, Vector2D(std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
|
||||
|
||||
Vector2D newSize = m_vBeginDragSizeXY;
|
||||
Vector2D newPos = m_vBeginDragPositionXY;
|
||||
Vector2D newSize = m_beginDragSizeXY;
|
||||
Vector2D newPos = m_beginDragPositionXY;
|
||||
|
||||
if (m_eGrabbedCorner == CORNER_BOTTOMRIGHT)
|
||||
if (m_grabbedCorner == CORNER_BOTTOMRIGHT)
|
||||
newSize = newSize + DELTA;
|
||||
else if (m_eGrabbedCorner == CORNER_TOPLEFT)
|
||||
else if (m_grabbedCorner == CORNER_TOPLEFT)
|
||||
newSize = newSize - DELTA;
|
||||
else if (m_eGrabbedCorner == CORNER_TOPRIGHT)
|
||||
else if (m_grabbedCorner == CORNER_TOPRIGHT)
|
||||
newSize = newSize + Vector2D(DELTA.x, -DELTA.y);
|
||||
else if (m_eGrabbedCorner == CORNER_BOTTOMLEFT)
|
||||
else if (m_grabbedCorner == CORNER_BOTTOMLEFT)
|
||||
newSize = newSize + Vector2D(-DELTA.x, DELTA.y);
|
||||
|
||||
eMouseBindMode mode = g_pInputManager->dragMode;
|
||||
if (DRAGGINGWINDOW->m_windowData.keepAspectRatio.valueOrDefault() && mode != MBIND_RESIZE_BLOCK_RATIO)
|
||||
mode = MBIND_RESIZE_FORCE_RATIO;
|
||||
|
||||
if (m_vBeginDragSizeXY.x >= 1 && m_vBeginDragSizeXY.y >= 1 && mode == MBIND_RESIZE_FORCE_RATIO) {
|
||||
if (m_beginDragSizeXY.x >= 1 && m_beginDragSizeXY.y >= 1 && mode == MBIND_RESIZE_FORCE_RATIO) {
|
||||
|
||||
const float RATIO = m_vBeginDragSizeXY.y / m_vBeginDragSizeXY.x;
|
||||
const float RATIO = m_beginDragSizeXY.y / m_beginDragSizeXY.x;
|
||||
|
||||
if (MINSIZE.x * RATIO > MINSIZE.y)
|
||||
MINSIZE = Vector2D(MINSIZE.x, MINSIZE.x * RATIO);
|
||||
@ -647,15 +647,15 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
|
||||
|
||||
newSize = newSize.clamp(MINSIZE, MAXSIZE);
|
||||
|
||||
if (m_eGrabbedCorner == CORNER_TOPLEFT)
|
||||
newPos = newPos - newSize + m_vBeginDragSizeXY;
|
||||
else if (m_eGrabbedCorner == CORNER_TOPRIGHT)
|
||||
newPos = newPos + Vector2D(0.0, (m_vBeginDragSizeXY - newSize).y);
|
||||
else if (m_eGrabbedCorner == CORNER_BOTTOMLEFT)
|
||||
newPos = newPos + Vector2D((m_vBeginDragSizeXY - newSize).x, 0.0);
|
||||
if (m_grabbedCorner == CORNER_TOPLEFT)
|
||||
newPos = newPos - newSize + m_beginDragSizeXY;
|
||||
else if (m_grabbedCorner == CORNER_TOPRIGHT)
|
||||
newPos = newPos + Vector2D(0.0, (m_beginDragSizeXY - newSize).y);
|
||||
else if (m_grabbedCorner == CORNER_BOTTOMLEFT)
|
||||
newPos = newPos + Vector2D((m_beginDragSizeXY - newSize).x, 0.0);
|
||||
|
||||
if (*SNAPENABLED) {
|
||||
performSnap(newPos, newSize, DRAGGINGWINDOW, mode, m_eGrabbedCorner, m_vBeginDragSizeXY);
|
||||
performSnap(newPos, newSize, DRAGGINGWINDOW, mode, m_grabbedCorner, m_beginDragSizeXY);
|
||||
newSize = newSize.clamp(MINSIZE, MAXSIZE);
|
||||
}
|
||||
|
||||
@ -674,7 +674,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
|
||||
DRAGGINGWINDOW->m_position = wb.pos();
|
||||
DRAGGINGWINDOW->m_size = wb.size();
|
||||
} else {
|
||||
resizeActiveWindow(TICKDELTA, m_eGrabbedCorner, DRAGGINGWINDOW);
|
||||
resizeActiveWindow(TICKDELTA, m_grabbedCorner, DRAGGINGWINDOW);
|
||||
}
|
||||
}
|
||||
|
||||
@ -747,7 +747,7 @@ void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) {
|
||||
g_pHyprRenderer->damageMonitor(pWindow->m_monitor.lock());
|
||||
|
||||
if (pWindow == g_pCompositor->m_lastWindow)
|
||||
m_pLastTiledWindow = pWindow;
|
||||
m_lastTiledWindow = pWindow;
|
||||
} else {
|
||||
onWindowRemovedTiling(pWindow);
|
||||
|
||||
@ -772,8 +772,8 @@ void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) {
|
||||
pWindow->unsetWindowData(PRIORITY_LAYOUT);
|
||||
pWindow->updateWindowData();
|
||||
|
||||
if (pWindow == m_pLastTiledWindow)
|
||||
m_pLastTiledWindow.reset();
|
||||
if (pWindow == m_lastTiledWindow)
|
||||
m_lastTiledWindow.reset();
|
||||
}
|
||||
|
||||
g_pCompositor->updateWindowAnimatedDecorationValues(pWindow);
|
||||
@ -801,7 +801,7 @@ void IHyprLayout::moveActiveWindow(const Vector2D& delta, PHLWINDOW pWindow) {
|
||||
}
|
||||
|
||||
void IHyprLayout::onWindowFocusChange(PHLWINDOW pNewFocus) {
|
||||
m_pLastTiledWindow = pNewFocus && !pNewFocus->m_isFloating ? pNewFocus : m_pLastTiledWindow;
|
||||
m_lastTiledWindow = pNewFocus && !pNewFocus->m_isFloating ? pNewFocus : m_lastTiledWindow;
|
||||
}
|
||||
|
||||
PHLWINDOW IHyprLayout::getNextWindowCandidate(PHLWINDOW pWindow) {
|
||||
@ -828,8 +828,8 @@ PHLWINDOW IHyprLayout::getNextWindowCandidate(PHLWINDOW pWindow) {
|
||||
}
|
||||
|
||||
// let's try the last tiled window.
|
||||
if (m_pLastTiledWindow.lock() && m_pLastTiledWindow->m_workspace == pWindow->m_workspace)
|
||||
return m_pLastTiledWindow.lock();
|
||||
if (m_lastTiledWindow.lock() && m_lastTiledWindow->m_workspace == pWindow->m_workspace)
|
||||
return m_lastTiledWindow.lock();
|
||||
|
||||
// if we don't, let's try to find any window that is in the middle
|
||||
if (const auto PWINDOWCANDIDATE = g_pCompositor->vectorToWindowUnified(pWindow->middle(), RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING);
|
||||
@ -960,8 +960,8 @@ bool IHyprLayout::updateDragWindow() {
|
||||
}
|
||||
}
|
||||
|
||||
DRAGGINGWINDOW->m_draggingTiled = false;
|
||||
m_vDraggingWindowOriginalFloatSize = DRAGGINGWINDOW->m_lastFloatingSize;
|
||||
DRAGGINGWINDOW->m_draggingTiled = false;
|
||||
m_draggingWindowOriginalFloatSize = DRAGGINGWINDOW->m_lastFloatingSize;
|
||||
|
||||
if (WAS_FULLSCREEN && DRAGGINGWINDOW->m_isFloating) {
|
||||
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
|
||||
@ -977,10 +977,10 @@ bool IHyprLayout::updateDragWindow() {
|
||||
}
|
||||
}
|
||||
|
||||
m_vBeginDragXY = g_pInputManager->getMouseCoordsInternal();
|
||||
m_vBeginDragPositionXY = DRAGGINGWINDOW->m_realPosition->goal();
|
||||
m_vBeginDragSizeXY = DRAGGINGWINDOW->m_realSize->goal();
|
||||
m_vLastDragXY = m_vBeginDragXY;
|
||||
m_beginDragXY = g_pInputManager->getMouseCoordsInternal();
|
||||
m_beginDragPositionXY = DRAGGINGWINDOW->m_realPosition->goal();
|
||||
m_beginDragSizeXY = DRAGGINGWINDOW->m_realSize->goal();
|
||||
m_lastDragXY = m_beginDragXY;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -212,13 +212,13 @@ class IHyprLayout {
|
||||
virtual bool updateDragWindow();
|
||||
|
||||
private:
|
||||
int m_iMouseMoveEventCount;
|
||||
Vector2D m_vBeginDragXY;
|
||||
Vector2D m_vLastDragXY;
|
||||
Vector2D m_vBeginDragPositionXY;
|
||||
Vector2D m_vBeginDragSizeXY;
|
||||
Vector2D m_vDraggingWindowOriginalFloatSize;
|
||||
eRectCorner m_eGrabbedCorner = CORNER_TOPLEFT;
|
||||
int m_mouseMoveEventCount;
|
||||
Vector2D m_beginDragXY;
|
||||
Vector2D m_lastDragXY;
|
||||
Vector2D m_beginDragPositionXY;
|
||||
Vector2D m_beginDragSizeXY;
|
||||
Vector2D m_draggingWindowOriginalFloatSize;
|
||||
eRectCorner m_grabbedCorner = CORNER_TOPLEFT;
|
||||
|
||||
PHLWINDOWREF m_pLastTiledWindow;
|
||||
PHLWINDOWREF m_lastTiledWindow;
|
||||
};
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "../managers/EventManager.hpp"
|
||||
|
||||
SMasterNodeData* CHyprMasterLayout::getNodeFromWindow(PHLWINDOW pWindow) {
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
for (auto& nd : m_masterNodesData) {
|
||||
if (nd.pWindow.lock() == pWindow)
|
||||
return &nd;
|
||||
}
|
||||
@ -21,7 +21,7 @@ SMasterNodeData* CHyprMasterLayout::getNodeFromWindow(PHLWINDOW pWindow) {
|
||||
|
||||
int CHyprMasterLayout::getNodesOnWorkspace(const WORKSPACEID& ws) {
|
||||
int no = 0;
|
||||
for (auto const& n : m_lMasterNodesData) {
|
||||
for (auto const& n : m_masterNodesData) {
|
||||
if (n.workspaceID == ws)
|
||||
no++;
|
||||
}
|
||||
@ -31,7 +31,7 @@ int CHyprMasterLayout::getNodesOnWorkspace(const WORKSPACEID& ws) {
|
||||
|
||||
int CHyprMasterLayout::getMastersOnWorkspace(const WORKSPACEID& ws) {
|
||||
int no = 0;
|
||||
for (auto const& n : m_lMasterNodesData) {
|
||||
for (auto const& n : m_masterNodesData) {
|
||||
if (n.workspaceID == ws && n.isMaster)
|
||||
no++;
|
||||
}
|
||||
@ -40,13 +40,13 @@ int CHyprMasterLayout::getMastersOnWorkspace(const WORKSPACEID& ws) {
|
||||
}
|
||||
|
||||
SMasterWorkspaceData* CHyprMasterLayout::getMasterWorkspaceData(const WORKSPACEID& ws) {
|
||||
for (auto& n : m_lMasterWorkspacesData) {
|
||||
for (auto& n : m_masterWorkspacesData) {
|
||||
if (n.workspaceID == ws)
|
||||
return &n;
|
||||
}
|
||||
|
||||
//create on the fly if it doesn't exist yet
|
||||
const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
|
||||
const auto PWORKSPACEDATA = &m_masterWorkspacesData.emplace_back();
|
||||
PWORKSPACEDATA->workspaceID = ws;
|
||||
static auto PORIENTATION = CConfigValue<std::string>("master:orientation");
|
||||
|
||||
@ -69,7 +69,7 @@ std::string CHyprMasterLayout::getLayoutName() {
|
||||
}
|
||||
|
||||
SMasterNodeData* CHyprMasterLayout::getMasterNodeOnWorkspace(const WORKSPACEID& ws) {
|
||||
for (auto& n : m_lMasterNodesData) {
|
||||
for (auto& n : m_masterNodesData) {
|
||||
if (n.isMaster && n.workspaceID == ws)
|
||||
return &n;
|
||||
}
|
||||
@ -94,13 +94,13 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire
|
||||
if (*PNEWONACTIVE != "none" && !BNEWISMASTER) {
|
||||
const auto pLastNode = getNodeFromWindow(g_pCompositor->m_lastWindow.lock());
|
||||
if (pLastNode && !(pLastNode->isMaster && (getMastersOnWorkspace(pWindow->workspaceID()) == 1 || *PNEWSTATUS == "slave"))) {
|
||||
auto it = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *pLastNode);
|
||||
auto it = std::find(m_masterNodesData.begin(), m_masterNodesData.end(), *pLastNode);
|
||||
if (!BNEWBEFOREACTIVE)
|
||||
++it;
|
||||
return &(*m_lMasterNodesData.emplace(it));
|
||||
return &(*m_masterNodesData.emplace(it));
|
||||
}
|
||||
}
|
||||
return *PNEWONTOP ? &m_lMasterNodesData.emplace_front() : &m_lMasterNodesData.emplace_back();
|
||||
return *PNEWONTOP ? &m_masterNodesData.emplace_front() : &m_masterNodesData.emplace_back();
|
||||
}();
|
||||
|
||||
PNODE->workspaceID = pWindow->workspaceID();
|
||||
@ -117,13 +117,13 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire
|
||||
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
|
||||
static auto PDROPATCURSOR = CConfigValue<Hyprlang::INT>("master:drop_at_cursor");
|
||||
eOrientation orientation = getDynamicOrientation(pWindow->m_workspace);
|
||||
const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE);
|
||||
const auto NODEIT = std::find(m_masterNodesData.begin(), m_masterNodesData.end(), *PNODE);
|
||||
|
||||
bool forceDropAsMaster = false;
|
||||
// if dragging window to move, drop it at the cursor position instead of bottom/top of stack
|
||||
if (*PDROPATCURSOR && g_pInputManager->dragMode == MBIND_MOVE) {
|
||||
if (WINDOWSONWORKSPACE > 2) {
|
||||
for (auto it = m_lMasterNodesData.begin(); it != m_lMasterNodesData.end(); ++it) {
|
||||
for (auto it = m_masterNodesData.begin(); it != m_masterNodesData.end(); ++it) {
|
||||
if (it->workspaceID != pWindow->workspaceID())
|
||||
continue;
|
||||
const CBox box = it->pWindow->getWindowIdealBoundingBoxIgnoreReserved();
|
||||
@ -142,14 +142,14 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire
|
||||
case ORIENTATION_CENTER: break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
m_lMasterNodesData.splice(it, m_lMasterNodesData, NODEIT);
|
||||
m_masterNodesData.splice(it, m_masterNodesData, NODEIT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (WINDOWSONWORKSPACE == 2) {
|
||||
// when dropping as the second tiled window in the workspace,
|
||||
// make it the master only if the cursor is on the master side of the screen
|
||||
for (auto const& nd : m_lMasterNodesData) {
|
||||
for (auto const& nd : m_masterNodesData) {
|
||||
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
|
||||
switch (orientation) {
|
||||
case ORIENTATION_LEFT:
|
||||
@ -184,7 +184,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire
|
||||
|| (*PNEWSTATUS == "inherit" && OPENINGON && OPENINGON->isMaster && g_pInputManager->dragMode != MBIND_MOVE)) {
|
||||
|
||||
if (BNEWBEFOREACTIVE) {
|
||||
for (auto& nd : m_lMasterNodesData | std::views::reverse) {
|
||||
for (auto& nd : m_masterNodesData | std::views::reverse) {
|
||||
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
|
||||
nd.isMaster = false;
|
||||
lastSplitPercent = nd.percMaster;
|
||||
@ -192,7 +192,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
for (auto& nd : m_masterNodesData) {
|
||||
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
|
||||
nd.isMaster = false;
|
||||
lastSplitPercent = nd.percMaster;
|
||||
@ -208,7 +208,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire
|
||||
if (const auto MAXSIZE = pWindow->requestedMaxSize(); MAXSIZE.x < PMONITOR->m_size.x * lastSplitPercent || MAXSIZE.y < PMONITOR->m_size.y) {
|
||||
// we can't continue. make it floating.
|
||||
pWindow->m_isFloating = true;
|
||||
m_lMasterNodesData.remove(*PNODE);
|
||||
m_masterNodesData.remove(*PNODE);
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow);
|
||||
return;
|
||||
}
|
||||
@ -221,7 +221,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire
|
||||
MAXSIZE.x < PMONITOR->m_size.x * (1 - lastSplitPercent) || MAXSIZE.y < PMONITOR->m_size.y * (1.f / (WINDOWSONWORKSPACE - 1))) {
|
||||
// we can't continue. make it floating.
|
||||
pWindow->m_isFloating = true;
|
||||
m_lMasterNodesData.remove(*PNODE);
|
||||
m_masterNodesData.remove(*PNODE);
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow);
|
||||
return;
|
||||
}
|
||||
@ -249,7 +249,7 @@ void CHyprMasterLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
|
||||
|
||||
if (PNODE->isMaster && (MASTERSLEFT <= 1 || *SMALLSPLIT == 1)) {
|
||||
// find a new master from top of the list
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
for (auto& nd : m_masterNodesData) {
|
||||
if (!nd.isMaster && nd.workspaceID == WORKSPACEID) {
|
||||
nd.isMaster = true;
|
||||
nd.percMaster = PNODE->percMaster;
|
||||
@ -258,10 +258,10 @@ void CHyprMasterLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
|
||||
}
|
||||
}
|
||||
|
||||
m_lMasterNodesData.remove(*PNODE);
|
||||
m_masterNodesData.remove(*PNODE);
|
||||
|
||||
if (getMastersOnWorkspace(WORKSPACEID) == getNodesOnWorkspace(WORKSPACEID) && MASTERSLEFT > 1) {
|
||||
for (auto& nd : m_lMasterNodesData | std::views::reverse) {
|
||||
for (auto& nd : m_masterNodesData | std::views::reverse) {
|
||||
if (nd.workspaceID == WORKSPACEID) {
|
||||
nd.isMaster = false;
|
||||
break;
|
||||
@ -271,7 +271,7 @@ void CHyprMasterLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
|
||||
// BUGFIX: correct bug where closing one master in a stack of 2 would leave
|
||||
// the screen half bare, and make it difficult to select remaining window
|
||||
if (getNodesOnWorkspace(WORKSPACEID) == 1) {
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
for (auto& nd : m_masterNodesData) {
|
||||
if (nd.workspaceID == WORKSPACEID && !nd.isMaster) {
|
||||
nd.isMaster = true;
|
||||
break;
|
||||
@ -363,7 +363,7 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) {
|
||||
if (*PSMARTRESIZING) {
|
||||
// check the total width and height so that later
|
||||
// if larger/smaller than screen size them down/up
|
||||
for (auto const& nd : m_lMasterNodesData) {
|
||||
for (auto const& nd : m_masterNodesData) {
|
||||
if (nd.workspaceID == pWorkspace->m_id) {
|
||||
if (nd.isMaster)
|
||||
masterAccumulatedSize += totalSize / MASTERS * nd.percSize;
|
||||
@ -404,7 +404,7 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) {
|
||||
if (orientation == ORIENTATION_BOTTOM)
|
||||
nextY = WSSIZE.y - HEIGHT;
|
||||
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
for (auto& nd : m_masterNodesData) {
|
||||
if (nd.workspaceID != pWorkspace->m_id || !nd.isMaster)
|
||||
continue;
|
||||
|
||||
@ -441,7 +441,7 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) {
|
||||
nextX = ((*PIGNORERESERVED && centerMasterWindow ? PMONITOR->m_size.x : WSSIZE.x) - WIDTH) / 2;
|
||||
}
|
||||
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
for (auto& nd : m_masterNodesData) {
|
||||
if (nd.workspaceID != pWorkspace->m_id || !nd.isMaster)
|
||||
continue;
|
||||
|
||||
@ -478,7 +478,7 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) {
|
||||
if (orientation == ORIENTATION_TOP)
|
||||
nextY = PMASTERNODE->size.y;
|
||||
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
for (auto& nd : m_masterNodesData) {
|
||||
if (nd.workspaceID != pWorkspace->m_id || nd.isMaster)
|
||||
continue;
|
||||
|
||||
@ -508,7 +508,7 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) {
|
||||
if (orientation == ORIENTATION_LEFT)
|
||||
nextX = PMASTERNODE->size.x;
|
||||
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
for (auto& nd : m_masterNodesData) {
|
||||
if (nd.workspaceID != pWorkspace->m_id || nd.isMaster)
|
||||
continue;
|
||||
|
||||
@ -553,7 +553,7 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) {
|
||||
float slaveAccumulatedHeightR = 0;
|
||||
|
||||
if (*PSMARTRESIZING) {
|
||||
for (auto const& nd : m_lMasterNodesData) {
|
||||
for (auto const& nd : m_masterNodesData) {
|
||||
if (nd.workspaceID != pWorkspace->m_id || nd.isMaster)
|
||||
continue;
|
||||
|
||||
@ -568,7 +568,7 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) {
|
||||
onRight = *CMSLAVESONRIGHT;
|
||||
}
|
||||
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
for (auto& nd : m_masterNodesData) {
|
||||
if (nd.workspaceID != pWorkspace->m_id || nd.isMaster)
|
||||
continue;
|
||||
|
||||
@ -701,7 +701,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
||||
*PWINDOW->m_realSize = wb.size();
|
||||
}
|
||||
|
||||
if (m_bForceWarps && !*PANIMATE) {
|
||||
if (m_forceWarps && !*PANIMATE) {
|
||||
g_pHyprRenderer->damageWindow(PWINDOW);
|
||||
|
||||
PWINDOW->m_realPosition->warp();
|
||||
@ -757,7 +757,7 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
||||
if (getNodesOnWorkspace(PWINDOW->workspaceID()) == 1 && !centered)
|
||||
return;
|
||||
|
||||
m_bForceWarps = true;
|
||||
m_forceWarps = true;
|
||||
|
||||
switch (orientation) {
|
||||
case ORIENTATION_LEFT: delta = pixResize.x / PMONITOR->m_size.x; break;
|
||||
@ -777,7 +777,7 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
||||
}
|
||||
|
||||
const auto workspaceIdForResizing = PMONITOR->m_activeSpecialWorkspace ? PMONITOR->activeSpecialWorkspaceID() : PMONITOR->activeWorkspaceID();
|
||||
for (auto& n : m_lMasterNodesData) {
|
||||
for (auto& n : m_masterNodesData) {
|
||||
if (n.isMaster && n.workspaceID == workspaceIdForResizing)
|
||||
n.percMaster = std::clamp(n.percMaster + delta, 0.05, 0.95);
|
||||
}
|
||||
@ -798,8 +798,8 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
||||
if (!*PSMARTRESIZING) {
|
||||
PNODE->percSize = std::clamp(PNODE->percSize + RESIZEDELTA / SIZE, 0.05, 1.95);
|
||||
} else {
|
||||
const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE);
|
||||
const auto REVNODEIT = std::find(m_lMasterNodesData.rbegin(), m_lMasterNodesData.rend(), *PNODE);
|
||||
const auto NODEIT = std::find(m_masterNodesData.begin(), m_masterNodesData.end(), *PNODE);
|
||||
const auto REVNODEIT = std::find(m_masterNodesData.rbegin(), m_masterNodesData.rend(), *PNODE);
|
||||
|
||||
const float totalSize = isStackVertical ? WSSIZE.y : WSSIZE.x;
|
||||
const float minSize = totalSize / nodesInSameColumn * 0.2;
|
||||
@ -820,10 +820,10 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
||||
};
|
||||
float resizeDiff;
|
||||
if (resizePrevNodes) {
|
||||
std::for_each(std::next(REVNODEIT), m_lMasterNodesData.rend(), checkNodesLeft);
|
||||
std::for_each(std::next(REVNODEIT), m_masterNodesData.rend(), checkNodesLeft);
|
||||
resizeDiff = -RESIZEDELTA;
|
||||
} else {
|
||||
std::for_each(std::next(NODEIT), m_lMasterNodesData.end(), checkNodesLeft);
|
||||
std::for_each(std::next(NODEIT), m_masterNodesData.end(), checkNodesLeft);
|
||||
resizeDiff = RESIZEDELTA;
|
||||
}
|
||||
|
||||
@ -849,16 +849,16 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
||||
it.percSize -= resizeDeltaForEach / SIZE;
|
||||
};
|
||||
if (resizePrevNodes) {
|
||||
std::for_each(std::next(REVNODEIT), m_lMasterNodesData.rend(), resizeNodesLeft);
|
||||
std::for_each(std::next(REVNODEIT), m_masterNodesData.rend(), resizeNodesLeft);
|
||||
} else {
|
||||
std::for_each(std::next(NODEIT), m_lMasterNodesData.end(), resizeNodesLeft);
|
||||
std::for_each(std::next(NODEIT), m_masterNodesData.end(), resizeNodesLeft);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recalculateMonitor(PMONITOR->m_id);
|
||||
|
||||
m_bForceWarps = false;
|
||||
m_forceWarps = false;
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::fullscreenRequestForWindow(PHLWINDOW pWindow, const eFullscreenMode CURRENT_EFFECTIVE_MODE, const eFullscreenMode EFFECTIVE_MODE) {
|
||||
@ -1018,7 +1018,7 @@ PHLWINDOW CHyprMasterLayout::getNextWindow(PHLWINDOW pWindow, bool next, bool lo
|
||||
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
||||
auto nodes = m_lMasterNodesData;
|
||||
auto nodes = m_masterNodesData;
|
||||
if (!next)
|
||||
std::reverse(nodes.begin(), nodes.end());
|
||||
|
||||
@ -1101,7 +1101,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
||||
const auto NEWFOCUS = newFocusToChild ? NEWCHILD : NEWMASTER;
|
||||
switchToWindow(NEWFOCUS);
|
||||
} else {
|
||||
for (auto const& n : m_lMasterNodesData) {
|
||||
for (auto const& n : m_masterNodesData) {
|
||||
if (n.workspaceID == PMASTER->workspaceID && !n.isMaster) {
|
||||
const auto NEWMASTER = n.pWindow.lock();
|
||||
switchWindows(NEWMASTER, NEWCHILD);
|
||||
@ -1136,7 +1136,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
||||
return 0;
|
||||
} else {
|
||||
// if master is focused keep master focused (don't do anything)
|
||||
for (auto const& n : m_lMasterNodesData) {
|
||||
for (auto const& n : m_masterNodesData) {
|
||||
if (n.workspaceID == PMASTER->workspaceID && !n.isMaster) {
|
||||
switchToWindow(n.pWindow.lock());
|
||||
break;
|
||||
@ -1217,7 +1217,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
||||
|
||||
if (!PNODE || PNODE->isMaster) {
|
||||
// first non-master node
|
||||
for (auto& n : m_lMasterNodesData) {
|
||||
for (auto& n : m_masterNodesData) {
|
||||
if (n.workspaceID == header.pWindow->workspaceID() && !n.isMaster) {
|
||||
n.isMaster = true;
|
||||
break;
|
||||
@ -1249,7 +1249,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
||||
|
||||
if (!PNODE || !PNODE->isMaster) {
|
||||
// first non-master node
|
||||
for (auto& nd : m_lMasterNodesData | std::views::reverse) {
|
||||
for (auto& nd : m_masterNodesData | std::views::reverse) {
|
||||
if (nd.workspaceID == header.pWindow->workspaceID() && nd.isMaster) {
|
||||
nd.isMaster = false;
|
||||
break;
|
||||
@ -1302,16 +1302,16 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
||||
if (!OLDMASTER)
|
||||
return 0;
|
||||
|
||||
const auto OLDMASTERIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *OLDMASTER);
|
||||
const auto OLDMASTERIT = std::find(m_masterNodesData.begin(), m_masterNodesData.end(), *OLDMASTER);
|
||||
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
for (auto& nd : m_masterNodesData) {
|
||||
if (nd.workspaceID == PNODE->workspaceID && !nd.isMaster) {
|
||||
nd.isMaster = true;
|
||||
const auto NEWMASTERIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), nd);
|
||||
m_lMasterNodesData.splice(OLDMASTERIT, m_lMasterNodesData, NEWMASTERIT);
|
||||
const auto NEWMASTERIT = std::find(m_masterNodesData.begin(), m_masterNodesData.end(), nd);
|
||||
m_masterNodesData.splice(OLDMASTERIT, m_masterNodesData, NEWMASTERIT);
|
||||
switchToWindow(nd.pWindow.lock());
|
||||
OLDMASTER->isMaster = false;
|
||||
m_lMasterNodesData.splice(m_lMasterNodesData.end(), m_lMasterNodesData, OLDMASTERIT);
|
||||
m_masterNodesData.splice(m_masterNodesData.end(), m_masterNodesData, OLDMASTERIT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1328,16 +1328,16 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
||||
if (!OLDMASTER)
|
||||
return 0;
|
||||
|
||||
const auto OLDMASTERIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *OLDMASTER);
|
||||
const auto OLDMASTERIT = std::find(m_masterNodesData.begin(), m_masterNodesData.end(), *OLDMASTER);
|
||||
|
||||
for (auto& nd : m_lMasterNodesData | std::views::reverse) {
|
||||
for (auto& nd : m_masterNodesData | std::views::reverse) {
|
||||
if (nd.workspaceID == PNODE->workspaceID && !nd.isMaster) {
|
||||
nd.isMaster = true;
|
||||
const auto NEWMASTERIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), nd);
|
||||
m_lMasterNodesData.splice(OLDMASTERIT, m_lMasterNodesData, NEWMASTERIT);
|
||||
const auto NEWMASTERIT = std::find(m_masterNodesData.begin(), m_masterNodesData.end(), nd);
|
||||
m_masterNodesData.splice(OLDMASTERIT, m_masterNodesData, NEWMASTERIT);
|
||||
switchToWindow(nd.pWindow.lock());
|
||||
OLDMASTER->isMaster = false;
|
||||
m_lMasterNodesData.splice(m_lMasterNodesData.begin(), m_lMasterNodesData, OLDMASTERIT);
|
||||
m_masterNodesData.splice(m_masterNodesData.begin(), m_masterNodesData, OLDMASTERIT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1477,5 +1477,5 @@ void CHyprMasterLayout::onEnable() {
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::onDisable() {
|
||||
m_lMasterNodesData.clear();
|
||||
m_masterNodesData.clear();
|
||||
}
|
||||
|
@ -71,10 +71,10 @@ class CHyprMasterLayout : public IHyprLayout {
|
||||
virtual void onDisable();
|
||||
|
||||
private:
|
||||
std::list<SMasterNodeData> m_lMasterNodesData;
|
||||
std::vector<SMasterWorkspaceData> m_lMasterWorkspacesData;
|
||||
std::list<SMasterNodeData> m_masterNodesData;
|
||||
std::vector<SMasterWorkspaceData> m_masterWorkspacesData;
|
||||
|
||||
bool m_bForceWarps = false;
|
||||
bool m_forceWarps = false;
|
||||
|
||||
void buildOrientationCycleVectorFromVars(std::vector<eOrientation>& cycle, CVarList& vars);
|
||||
void buildOrientationCycleVectorFromEOperation(std::vector<eOrientation>& cycle);
|
||||
|
Loading…
x
Reference in New Issue
Block a user