internal: Window storage rework - part 1 (#5762)
* Window storage rework - part 1 * format * remove useless include * fix pch * format * fix crash in dwindle * fix vram leak * prefer .expired() for bool checks
This commit is contained in:
parent
25aec3ac8c
commit
bca7804bb6
72 changed files with 1416 additions and 1346 deletions
|
|
@ -58,7 +58,7 @@ int CHyprDwindleLayout::getNodesOnWorkspace(const int& id) {
|
|||
|
||||
SDwindleNodeData* CHyprDwindleLayout::getFirstNodeOnWorkspace(const int& id) {
|
||||
for (auto& n : m_lDwindleNodesData) {
|
||||
if (n.workspaceID == id && n.pWindow && g_pCompositor->windowValidMapped(n.pWindow))
|
||||
if (n.workspaceID == id && validMapped(n.pWindow))
|
||||
return &n;
|
||||
}
|
||||
return nullptr;
|
||||
|
|
@ -68,7 +68,7 @@ SDwindleNodeData* CHyprDwindleLayout::getClosestNodeOnWorkspace(const int& id, c
|
|||
SDwindleNodeData* res = nullptr;
|
||||
double distClosest = -1;
|
||||
for (auto& n : m_lDwindleNodesData) {
|
||||
if (n.workspaceID == id && n.pWindow && g_pCompositor->windowValidMapped(n.pWindow)) {
|
||||
if (n.workspaceID == id && validMapped(n.pWindow)) {
|
||||
auto distAnother = vecToRectDistanceSquared(point, n.box.pos(), n.box.pos() + n.box.size());
|
||||
if (!res || distAnother < distClosest) {
|
||||
res = &n;
|
||||
|
|
@ -79,9 +79,9 @@ SDwindleNodeData* CHyprDwindleLayout::getClosestNodeOnWorkspace(const int& id, c
|
|||
return res;
|
||||
}
|
||||
|
||||
SDwindleNodeData* CHyprDwindleLayout::getNodeFromWindow(CWindow* pWindow) {
|
||||
SDwindleNodeData* CHyprDwindleLayout::getNodeFromWindow(PHLWINDOW pWindow) {
|
||||
for (auto& n : m_lDwindleNodesData) {
|
||||
if (n.pWindow == pWindow && !n.isNode)
|
||||
if (n.pWindow.lock() == pWindow && !n.isNode)
|
||||
return &n;
|
||||
}
|
||||
|
||||
|
|
@ -125,12 +125,12 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
|||
const bool DISPLAYTOP = STICKS(pNode->box.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
||||
const bool DISPLAYBOTTOM = STICKS(pNode->box.y + pNode->box.h, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
||||
|
||||
const auto PWINDOW = pNode->pWindow;
|
||||
const auto PWINDOW = pNode->pWindow.lock();
|
||||
// get specific gaps and rules for this workspace,
|
||||
// if user specified them in config
|
||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(g_pCompositor->getWorkspaceByID(pNode->workspaceID));
|
||||
|
||||
if (!g_pCompositor->windowExists(PWINDOW)) {
|
||||
if (!validMapped(PWINDOW)) {
|
||||
Debug::log(ERR, "Node {} holding invalid {}!!", pNode, PWINDOW);
|
||||
onWindowRemovedTiling(PWINDOW);
|
||||
return;
|
||||
|
|
@ -248,7 +248,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
|||
PWINDOW->updateWindowDecos();
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direction) {
|
||||
void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection direction) {
|
||||
if (pWindow->m_bIsFloating)
|
||||
return;
|
||||
|
||||
|
|
@ -282,9 +282,9 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
|
|||
OPENINGON = getClosestNodeOnWorkspace(PNODE->workspaceID, MOUSECOORDS);
|
||||
|
||||
} else if (*PUSEACTIVE) {
|
||||
if (g_pCompositor->m_pLastWindow && !g_pCompositor->m_pLastWindow->m_bIsFloating && g_pCompositor->m_pLastWindow != pWindow &&
|
||||
g_pCompositor->m_pLastWindow->m_pWorkspace == pWindow->m_pWorkspace && g_pCompositor->m_pLastWindow->m_bIsMapped) {
|
||||
OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow);
|
||||
if (g_pCompositor->m_pLastWindow.lock() && !g_pCompositor->m_pLastWindow.lock()->m_bIsFloating && g_pCompositor->m_pLastWindow.lock() != pWindow &&
|
||||
g_pCompositor->m_pLastWindow.lock()->m_pWorkspace == pWindow->m_pWorkspace && g_pCompositor->m_pLastWindow.lock()->m_bIsMapped) {
|
||||
OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow.lock());
|
||||
} else {
|
||||
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS));
|
||||
}
|
||||
|
|
@ -313,9 +313,9 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
|
|||
}
|
||||
|
||||
// last fail-safe to avoid duplicate fullscreens
|
||||
if ((!OPENINGON || OPENINGON->pWindow == pWindow) && getNodesOnWorkspace(PNODE->workspaceID) > 1) {
|
||||
if ((!OPENINGON || OPENINGON->pWindow.lock() == pWindow) && getNodesOnWorkspace(PNODE->workspaceID) > 1) {
|
||||
for (auto& node : m_lDwindleNodesData) {
|
||||
if (node.workspaceID == PNODE->workspaceID && node.pWindow != nullptr && node.pWindow != pWindow) {
|
||||
if (node.workspaceID == PNODE->workspaceID && node.pWindow.lock() && node.pWindow.lock() != pWindow) {
|
||||
OPENINGON = &node;
|
||||
break;
|
||||
}
|
||||
|
|
@ -323,7 +323,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
|
|||
}
|
||||
|
||||
// if it's the first, it's easy. Make it fullscreen.
|
||||
if (!OPENINGON || OPENINGON->pWindow == pWindow) {
|
||||
if (!OPENINGON || OPENINGON->pWindow.lock() == pWindow) {
|
||||
PNODE->box = CBox{PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight};
|
||||
|
||||
applyNodeDataToWindow(PNODE);
|
||||
|
|
@ -334,19 +334,19 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
|
|||
}
|
||||
|
||||
if (!m_vOverrideFocalPoint && g_pInputManager->m_bWasDraggingWindow) {
|
||||
if (OPENINGON->pWindow->checkInputOnDecos(INPUT_TYPE_DRAG_END, MOUSECOORDS, pWindow))
|
||||
if (OPENINGON->pWindow.lock()->checkInputOnDecos(INPUT_TYPE_DRAG_END, MOUSECOORDS, pWindow))
|
||||
return;
|
||||
}
|
||||
|
||||
// if it's a group, add the window
|
||||
if (OPENINGON->pWindow->m_sGroupData.pNextWindow // target is group
|
||||
&& pWindow->canBeGroupedInto(OPENINGON->pWindow) && !m_vOverrideFocalPoint) { // we are not moving window
|
||||
if (OPENINGON->pWindow.lock()->m_sGroupData.pNextWindow.lock() // target is group
|
||||
&& pWindow->canBeGroupedInto(OPENINGON->pWindow.lock()) && !m_vOverrideFocalPoint) { // we are not moving window
|
||||
m_lDwindleNodesData.remove(*PNODE);
|
||||
|
||||
static auto USECURRPOS = CConfigValue<Hyprlang::INT>("group:insert_after_current");
|
||||
(*USECURRPOS ? OPENINGON->pWindow : OPENINGON->pWindow->getGroupTail())->insertWindowToGroup(pWindow);
|
||||
(*USECURRPOS ? OPENINGON->pWindow.lock() : OPENINGON->pWindow.lock()->getGroupTail())->insertWindowToGroup(pWindow);
|
||||
|
||||
OPENINGON->pWindow->setGroupCurrent(pWindow);
|
||||
OPENINGON->pWindow.lock()->setGroupCurrent(pWindow);
|
||||
pWindow->applyGroupRules();
|
||||
pWindow->updateWindowDecos();
|
||||
recalculateWindow(pWindow);
|
||||
|
|
@ -487,7 +487,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
|
|||
pWindow->applyGroupRules();
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
||||
void CHyprDwindleLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
|
||||
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
||||
|
|
@ -585,7 +585,7 @@ void CHyprDwindleLayout::calculateWorkspace(const PHLWORKSPACE& pWorkspace) {
|
|||
}
|
||||
}
|
||||
|
||||
bool CHyprDwindleLayout::isWindowTiled(CWindow* pWindow) {
|
||||
bool CHyprDwindleLayout::isWindowTiled(PHLWINDOW pWindow) {
|
||||
return getNodeFromWindow(pWindow) != nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -595,11 +595,11 @@ void CHyprDwindleLayout::onBeginDragWindow() {
|
|||
IHyprLayout::onBeginDragWindow();
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorner corner, CWindow* pWindow) {
|
||||
void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorner corner, PHLWINDOW pWindow) {
|
||||
|
||||
const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_pLastWindow;
|
||||
const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_pLastWindow.lock();
|
||||
|
||||
if (!g_pCompositor->windowValidMapped(PWINDOW))
|
||||
if (!validMapped(PWINDOW))
|
||||
return;
|
||||
|
||||
const auto PNODE = getNodeFromWindow(PWINDOW);
|
||||
|
|
@ -786,8 +786,8 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
|
|||
}
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreenMode fullscreenMode, bool on) {
|
||||
if (!g_pCompositor->windowValidMapped(pWindow))
|
||||
void CHyprDwindleLayout::fullscreenRequestForWindow(PHLWINDOW pWindow, eFullscreenMode fullscreenMode, bool on) {
|
||||
if (!validMapped(pWindow))
|
||||
return;
|
||||
|
||||
if (on == pWindow->m_bIsFullscreen)
|
||||
|
|
@ -867,7 +867,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
|
|||
recalculateMonitor(PMONITOR->ID);
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::recalculateWindow(CWindow* pWindow) {
|
||||
void CHyprDwindleLayout::recalculateWindow(PHLWINDOW pWindow) {
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
||||
if (!PNODE)
|
||||
|
|
@ -886,7 +886,7 @@ void addToDequeRecursive(std::deque<SDwindleNodeData*>* pDeque, std::deque<SDwin
|
|||
}
|
||||
}
|
||||
|
||||
SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow) {
|
||||
SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(PHLWINDOW pWindow) {
|
||||
// window should be valid, insallah
|
||||
SWindowRenderLayoutHints hints;
|
||||
|
||||
|
|
@ -897,7 +897,7 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow
|
|||
return hints;
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::moveWindowTo(CWindow* pWindow, const std::string& dir, bool silent) {
|
||||
void CHyprDwindleLayout::moveWindowTo(PHLWINDOW pWindow, const std::string& dir, bool silent) {
|
||||
if (!isDirection(dir))
|
||||
return;
|
||||
|
||||
|
|
@ -940,12 +940,12 @@ void CHyprDwindleLayout::moveWindowTo(CWindow* pWindow, const std::string& dir,
|
|||
// restore focus to the previous position
|
||||
if (silent) {
|
||||
const auto PNODETOFOCUS = getClosestNodeOnWorkspace(originalWorkspaceID, originalPos);
|
||||
if (PNODETOFOCUS && PNODETOFOCUS->pWindow)
|
||||
g_pCompositor->focusWindow(PNODETOFOCUS->pWindow);
|
||||
if (PNODETOFOCUS && PNODETOFOCUS->pWindow.lock())
|
||||
g_pCompositor->focusWindow(PNODETOFOCUS->pWindow.lock());
|
||||
}
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
||||
void CHyprDwindleLayout::switchWindows(PHLWINDOW pWindow, PHLWINDOW pWindow2) {
|
||||
// windows should be valid, insallah
|
||||
|
||||
auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
|
@ -984,15 +984,15 @@ void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
|||
getMasterNodeOnWorkspace(PNODE2->workspaceID)->recalcSizePosRecursive();
|
||||
|
||||
if (ACTIVE1) {
|
||||
ACTIVE1->box = PNODE->box;
|
||||
ACTIVE1->pWindow->m_vPosition = ACTIVE1->box.pos();
|
||||
ACTIVE1->pWindow->m_vSize = ACTIVE1->box.size();
|
||||
ACTIVE1->box = PNODE->box;
|
||||
ACTIVE1->pWindow.lock()->m_vPosition = ACTIVE1->box.pos();
|
||||
ACTIVE1->pWindow.lock()->m_vSize = ACTIVE1->box.size();
|
||||
}
|
||||
|
||||
if (ACTIVE2) {
|
||||
ACTIVE2->box = PNODE2->box;
|
||||
ACTIVE2->pWindow->m_vPosition = ACTIVE2->box.pos();
|
||||
ACTIVE2->pWindow->m_vSize = ACTIVE2->box.size();
|
||||
ACTIVE2->box = PNODE2->box;
|
||||
ACTIVE2->pWindow.lock()->m_vPosition = ACTIVE2->box.pos();
|
||||
ACTIVE2->pWindow.lock()->m_vSize = ACTIVE2->box.size();
|
||||
}
|
||||
|
||||
g_pHyprRenderer->damageWindow(pWindow);
|
||||
|
|
@ -1004,7 +1004,7 @@ void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
|||
g_pCompositor->setWindowFullscreen(pWindow, true);
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::alterSplitRatio(CWindow* pWindow, float ratio, bool exact) {
|
||||
void CHyprDwindleLayout::alterSplitRatio(PHLWINDOW pWindow, float ratio, bool exact) {
|
||||
// window should be valid, insallah
|
||||
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
|
@ -1063,7 +1063,7 @@ std::any CHyprDwindleLayout::layoutMessage(SLayoutMessageHeader header, std::str
|
|||
return "";
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::toggleSplit(CWindow* pWindow) {
|
||||
void CHyprDwindleLayout::toggleSplit(PHLWINDOW pWindow) {
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
||||
if (!PNODE || !PNODE->pParent)
|
||||
|
|
@ -1077,7 +1077,7 @@ void CHyprDwindleLayout::toggleSplit(CWindow* pWindow) {
|
|||
PNODE->pParent->recalcSizePosRecursive();
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::swapSplit(CWindow* pWindow) {
|
||||
void CHyprDwindleLayout::swapSplit(PHLWINDOW pWindow) {
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
||||
if (!PNODE || !PNODE->pParent)
|
||||
|
|
@ -1091,7 +1091,7 @@ void CHyprDwindleLayout::swapSplit(CWindow* pWindow) {
|
|||
PNODE->pParent->recalcSizePosRecursive();
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::replaceWindowDataWith(CWindow* from, CWindow* to) {
|
||||
void CHyprDwindleLayout::replaceWindowDataWith(PHLWINDOW from, PHLWINDOW to) {
|
||||
const auto PNODE = getNodeFromWindow(from);
|
||||
|
||||
if (!PNODE)
|
||||
|
|
@ -1111,7 +1111,7 @@ void CHyprDwindleLayout::onEnable() {
|
|||
if (w->m_bIsFloating || !w->m_bIsMapped || w->isHidden())
|
||||
continue;
|
||||
|
||||
onWindowCreatedTiling(w.get());
|
||||
onWindowCreatedTiling(w);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1124,7 +1124,7 @@ Vector2D CHyprDwindleLayout::predictSizeForNewWindowTiled() {
|
|||
return {};
|
||||
|
||||
// get window candidate
|
||||
CWindow* candidate = g_pCompositor->m_pLastWindow;
|
||||
PHLWINDOW candidate = g_pCompositor->m_pLastWindow.lock();
|
||||
|
||||
if (!candidate)
|
||||
candidate = g_pCompositor->getFirstWindowOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace->m_iID);
|
||||
|
|
@ -1140,8 +1140,8 @@ Vector2D CHyprDwindleLayout::predictSizeForNewWindowTiled() {
|
|||
if (!PNODE)
|
||||
return {};
|
||||
|
||||
node = *PNODE;
|
||||
node.pWindow = nullptr;
|
||||
node = *PNODE;
|
||||
node.pWindow.reset();
|
||||
|
||||
CBox box = PNODE->box;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ struct SDwindleNodeData {
|
|||
SDwindleNodeData* pParent = nullptr;
|
||||
bool isNode = false;
|
||||
|
||||
CWindow* pWindow = nullptr;
|
||||
PHLWINDOWREF pWindow;
|
||||
|
||||
std::array<SDwindleNodeData*, 2> children = {nullptr, nullptr};
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ struct SDwindleNodeData {
|
|||
|
||||
// For list lookup
|
||||
bool operator==(const SDwindleNodeData& rhs) const {
|
||||
return pWindow == rhs.pWindow && workspaceID == rhs.workspaceID && box == rhs.box && pParent == rhs.pParent && children[0] == rhs.children[0] &&
|
||||
return pWindow.lock() == rhs.pWindow.lock() && workspaceID == rhs.workspaceID && box == rhs.box && pParent == rhs.pParent && children[0] == rhs.children[0] &&
|
||||
children[1] == rhs.children[1];
|
||||
}
|
||||
|
||||
|
|
@ -45,21 +45,21 @@ struct SDwindleNodeData {
|
|||
|
||||
class CHyprDwindleLayout : public IHyprLayout {
|
||||
public:
|
||||
virtual void onWindowCreatedTiling(CWindow*, eDirection direction = DIRECTION_DEFAULT);
|
||||
virtual void onWindowRemovedTiling(CWindow*);
|
||||
virtual bool isWindowTiled(CWindow*);
|
||||
virtual void onWindowCreatedTiling(PHLWINDOW, eDirection direction = DIRECTION_DEFAULT);
|
||||
virtual void onWindowRemovedTiling(PHLWINDOW);
|
||||
virtual bool isWindowTiled(PHLWINDOW);
|
||||
virtual void recalculateMonitor(const int&);
|
||||
virtual void recalculateWindow(CWindow*);
|
||||
virtual void recalculateWindow(PHLWINDOW);
|
||||
virtual void onBeginDragWindow();
|
||||
virtual void resizeActiveWindow(const Vector2D&, eRectCorner corner = CORNER_NONE, CWindow* pWindow = nullptr);
|
||||
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
|
||||
virtual void resizeActiveWindow(const Vector2D&, eRectCorner corner = CORNER_NONE, PHLWINDOW pWindow = nullptr);
|
||||
virtual void fullscreenRequestForWindow(PHLWINDOW, eFullscreenMode, bool);
|
||||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
||||
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
||||
virtual void switchWindows(CWindow*, CWindow*);
|
||||
virtual void moveWindowTo(CWindow*, const std::string& dir, bool silent);
|
||||
virtual void alterSplitRatio(CWindow*, float, bool);
|
||||
virtual SWindowRenderLayoutHints requestRenderHints(PHLWINDOW);
|
||||
virtual void switchWindows(PHLWINDOW, PHLWINDOW);
|
||||
virtual void moveWindowTo(PHLWINDOW, const std::string& dir, bool silent);
|
||||
virtual void alterSplitRatio(PHLWINDOW, float, bool);
|
||||
virtual std::string getLayoutName();
|
||||
virtual void replaceWindowDataWith(CWindow* from, CWindow* to);
|
||||
virtual void replaceWindowDataWith(PHLWINDOW from, PHLWINDOW to);
|
||||
virtual Vector2D predictSizeForNewWindowTiled();
|
||||
|
||||
virtual void onEnable();
|
||||
|
|
@ -80,13 +80,13 @@ class CHyprDwindleLayout : public IHyprLayout {
|
|||
int getNodesOnWorkspace(const int&);
|
||||
void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
|
||||
void calculateWorkspace(const PHLWORKSPACE& pWorkspace);
|
||||
SDwindleNodeData* getNodeFromWindow(CWindow*);
|
||||
SDwindleNodeData* getNodeFromWindow(PHLWINDOW);
|
||||
SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
|
||||
SDwindleNodeData* getClosestNodeOnWorkspace(const int&, const Vector2D&);
|
||||
SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
|
||||
|
||||
void toggleSplit(CWindow*);
|
||||
void swapSplit(CWindow*);
|
||||
void toggleSplit(PHLWINDOW);
|
||||
void swapSplit(PHLWINDOW);
|
||||
|
||||
eDirection overrideDirection = DIRECTION_DEFAULT;
|
||||
|
||||
|
|
@ -101,8 +101,8 @@ struct std::formatter<SDwindleNodeData*, CharT> : std::formatter<CharT> {
|
|||
if (!node)
|
||||
return std::format_to(out, "[Node nullptr]");
|
||||
std::format_to(out, "[Node {:x}: workspace: {}, pos: {:j2}, size: {:j2}", (uintptr_t)node, node->workspaceID, node->box.pos(), node->box.size());
|
||||
if (!node->isNode && node->pWindow)
|
||||
std::format_to(out, ", window: {:x}", node->pWindow);
|
||||
if (!node->isNode && !node->pWindow.expired())
|
||||
std::format_to(out, ", window: {:x}", node->pWindow.lock());
|
||||
return std::format_to(out, "]");
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "../config/ConfigValue.hpp"
|
||||
#include "../desktop/Window.hpp"
|
||||
|
||||
void IHyprLayout::onWindowCreated(CWindow* pWindow, eDirection direction) {
|
||||
void IHyprLayout::onWindowCreated(PHLWINDOW pWindow, eDirection direction) {
|
||||
if (pWindow->m_bIsFloating) {
|
||||
onWindowCreatedFloating(pWindow);
|
||||
} else {
|
||||
|
|
@ -25,32 +25,32 @@ void IHyprLayout::onWindowCreated(CWindow* pWindow, eDirection direction) {
|
|||
}
|
||||
}
|
||||
|
||||
void IHyprLayout::onWindowRemoved(CWindow* pWindow) {
|
||||
void IHyprLayout::onWindowRemoved(PHLWINDOW pWindow) {
|
||||
if (pWindow->m_bIsFullscreen)
|
||||
g_pCompositor->setWindowFullscreen(pWindow, false, FULLSCREEN_FULL);
|
||||
|
||||
if (pWindow->m_sGroupData.pNextWindow) {
|
||||
if (pWindow->m_sGroupData.pNextWindow == pWindow)
|
||||
pWindow->m_sGroupData.pNextWindow = nullptr;
|
||||
if (!pWindow->m_sGroupData.pNextWindow.expired()) {
|
||||
if (pWindow->m_sGroupData.pNextWindow.lock() == pWindow)
|
||||
pWindow->m_sGroupData.pNextWindow.reset();
|
||||
else {
|
||||
// find last window and update
|
||||
CWindow* PWINDOWPREV = pWindow->getGroupPrevious();
|
||||
PHLWINDOW PWINDOWPREV = pWindow->getGroupPrevious();
|
||||
const auto WINDOWISVISIBLE = pWindow->getGroupCurrent() == pWindow;
|
||||
|
||||
if (WINDOWISVISIBLE)
|
||||
PWINDOWPREV->setGroupCurrent(pWindow->m_sGroupData.head ? pWindow->m_sGroupData.pNextWindow : PWINDOWPREV);
|
||||
PWINDOWPREV->setGroupCurrent(pWindow->m_sGroupData.head ? pWindow->m_sGroupData.pNextWindow.lock() : PWINDOWPREV);
|
||||
|
||||
PWINDOWPREV->m_sGroupData.pNextWindow = pWindow->m_sGroupData.pNextWindow;
|
||||
|
||||
pWindow->m_sGroupData.pNextWindow = nullptr;
|
||||
pWindow->m_sGroupData.pNextWindow.reset();
|
||||
|
||||
if (pWindow->m_sGroupData.head) {
|
||||
std::swap(PWINDOWPREV->m_sGroupData.pNextWindow->m_sGroupData.head, pWindow->m_sGroupData.head);
|
||||
std::swap(PWINDOWPREV->m_sGroupData.pNextWindow->m_sGroupData.locked, pWindow->m_sGroupData.locked);
|
||||
std::swap(PWINDOWPREV->m_sGroupData.pNextWindow.lock()->m_sGroupData.head, pWindow->m_sGroupData.head);
|
||||
std::swap(PWINDOWPREV->m_sGroupData.pNextWindow.lock()->m_sGroupData.locked, pWindow->m_sGroupData.locked);
|
||||
}
|
||||
|
||||
if (pWindow == m_pLastTiledWindow)
|
||||
m_pLastTiledWindow = nullptr;
|
||||
if (pWindow == m_pLastTiledWindow.lock())
|
||||
m_pLastTiledWindow.reset();
|
||||
|
||||
pWindow->setHidden(false);
|
||||
|
||||
|
|
@ -68,15 +68,15 @@ void IHyprLayout::onWindowRemoved(CWindow* pWindow) {
|
|||
onWindowRemovedTiling(pWindow);
|
||||
}
|
||||
|
||||
if (pWindow == m_pLastTiledWindow)
|
||||
m_pLastTiledWindow = nullptr;
|
||||
if (pWindow == m_pLastTiledWindow.lock())
|
||||
m_pLastTiledWindow.reset();
|
||||
}
|
||||
|
||||
void IHyprLayout::onWindowRemovedFloating(CWindow* pWindow) {
|
||||
void IHyprLayout::onWindowRemovedFloating(PHLWINDOW pWindow) {
|
||||
return; // no-op
|
||||
}
|
||||
|
||||
void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
||||
void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) {
|
||||
|
||||
CBox desiredGeometry = {0};
|
||||
g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry);
|
||||
|
|
@ -172,15 +172,15 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
|||
}
|
||||
|
||||
void IHyprLayout::onBeginDragWindow() {
|
||||
const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow;
|
||||
const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow.lock();
|
||||
|
||||
m_iMouseMoveEventCount = 1;
|
||||
m_vBeginDragSizeXY = Vector2D();
|
||||
|
||||
// Window will be floating. Let's check if it's valid. It should be, but I don't like crashing.
|
||||
if (!g_pCompositor->windowValidMapped(DRAGGINGWINDOW)) {
|
||||
if (!validMapped(DRAGGINGWINDOW)) {
|
||||
Debug::log(ERR, "Dragging attempted on an invalid window!");
|
||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||
g_pInputManager->currentlyDraggedWindow.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ void IHyprLayout::onBeginDragWindow() {
|
|||
|
||||
if (PWORKSPACE->m_bHasFullscreenWindow && (!DRAGGINGWINDOW->m_bCreatedOverFullscreen || !DRAGGINGWINDOW->m_bIsFloating)) {
|
||||
Debug::log(LOG, "Rejecting drag on a fullscreen workspace. (window under fullscreen)");
|
||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||
g_pInputManager->currentlyDraggedWindow.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -268,22 +268,22 @@ void IHyprLayout::onBeginDragWindow() {
|
|||
}
|
||||
|
||||
void IHyprLayout::onEndDragWindow() {
|
||||
const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow;
|
||||
const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow.lock();
|
||||
|
||||
m_iMouseMoveEventCount = 1;
|
||||
|
||||
if (!g_pCompositor->windowValidMapped(DRAGGINGWINDOW)) {
|
||||
if (!validMapped(DRAGGINGWINDOW)) {
|
||||
if (DRAGGINGWINDOW) {
|
||||
g_pInputManager->unsetCursorImage();
|
||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||
g_pInputManager->currentlyDraggedWindow.reset();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
g_pInputManager->unsetCursorImage();
|
||||
|
||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||
g_pInputManager->m_bWasDraggingWindow = true;
|
||||
g_pInputManager->currentlyDraggedWindow.reset();
|
||||
g_pInputManager->m_bWasDraggingWindow = true;
|
||||
|
||||
if (DRAGGINGWINDOW->m_bDraggingTiled) {
|
||||
DRAGGINGWINDOW->m_bIsFloating = false;
|
||||
|
|
@ -293,13 +293,13 @@ void IHyprLayout::onEndDragWindow() {
|
|||
} else if (g_pInputManager->dragMode == MBIND_MOVE) {
|
||||
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
|
||||
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
|
||||
CWindow* pWindow = g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING | FLOATING_ONLY, DRAGGINGWINDOW);
|
||||
PHLWINDOW pWindow = g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING | FLOATING_ONLY, DRAGGINGWINDOW);
|
||||
|
||||
if (pWindow) {
|
||||
if (pWindow->checkInputOnDecos(INPUT_TYPE_DRAG_END, MOUSECOORDS, DRAGGINGWINDOW))
|
||||
return;
|
||||
|
||||
if (pWindow->m_sGroupData.pNextWindow && DRAGGINGWINDOW->canBeGroupedInto(pWindow)) {
|
||||
if (pWindow->m_sGroupData.pNextWindow.lock() && DRAGGINGWINDOW->canBeGroupedInto(pWindow)) {
|
||||
static auto USECURRPOS = CConfigValue<Hyprlang::INT>("group:insert_after_current");
|
||||
(*USECURRPOS ? pWindow : pWindow->getGroupTail())->insertWindowToGroup(DRAGGINGWINDOW);
|
||||
pWindow->setGroupCurrent(DRAGGINGWINDOW);
|
||||
|
|
@ -318,12 +318,12 @@ void IHyprLayout::onEndDragWindow() {
|
|||
}
|
||||
|
||||
void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
|
||||
const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow;
|
||||
const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow.lock();
|
||||
|
||||
// Window invalid or drag begin size 0,0 meaning we rejected it.
|
||||
if (!g_pCompositor->windowValidMapped(DRAGGINGWINDOW) || m_vBeginDragSizeXY == Vector2D()) {
|
||||
if (!validMapped(DRAGGINGWINDOW) || m_vBeginDragSizeXY == Vector2D()) {
|
||||
onEndDragWindow();
|
||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||
g_pInputManager->currentlyDraggedWindow.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -461,7 +461,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
|
|||
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
|
||||
}
|
||||
|
||||
void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
|
||||
void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) {
|
||||
|
||||
if (pWindow->m_bIsFullscreen) {
|
||||
Debug::log(LOG, "changeWindowFloatingMode: fullscreen");
|
||||
|
|
@ -473,7 +473,7 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
|
|||
const auto TILED = isWindowTiled(pWindow);
|
||||
|
||||
// event
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"changefloatingmode", std::format("{:x},{}", (uintptr_t)pWindow, (int)TILED)});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"changefloatingmode", std::format("{:x},{}", (uintptr_t)pWindow.get(), (int)TILED)});
|
||||
EMIT_HOOK_EVENT("changeFloatingMode", pWindow);
|
||||
|
||||
if (!TILED) {
|
||||
|
|
@ -508,7 +508,7 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
|
|||
// fix pseudo leaving artifacts
|
||||
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID));
|
||||
|
||||
if (pWindow == g_pCompositor->m_pLastWindow)
|
||||
if (pWindow == g_pCompositor->m_pLastWindow.lock())
|
||||
m_pLastTiledWindow = pWindow;
|
||||
} else {
|
||||
onWindowRemovedTiling(pWindow);
|
||||
|
|
@ -533,8 +533,8 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
|
|||
|
||||
pWindow->updateSpecialRenderData();
|
||||
|
||||
if (pWindow == m_pLastTiledWindow)
|
||||
m_pLastTiledWindow = nullptr;
|
||||
if (pWindow == m_pLastTiledWindow.lock())
|
||||
m_pLastTiledWindow.reset();
|
||||
}
|
||||
|
||||
g_pCompositor->updateWindowAnimatedDecorationValues(pWindow);
|
||||
|
|
@ -542,10 +542,10 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
|
|||
pWindow->updateToplevel();
|
||||
}
|
||||
|
||||
void IHyprLayout::moveActiveWindow(const Vector2D& delta, CWindow* pWindow) {
|
||||
const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_pLastWindow;
|
||||
void IHyprLayout::moveActiveWindow(const Vector2D& delta, PHLWINDOW pWindow) {
|
||||
const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_pLastWindow.lock();
|
||||
|
||||
if (!g_pCompositor->windowValidMapped(PWINDOW))
|
||||
if (!validMapped(PWINDOW))
|
||||
return;
|
||||
|
||||
if (!PWINDOW->m_bIsFloating) {
|
||||
|
|
@ -560,11 +560,11 @@ void IHyprLayout::moveActiveWindow(const Vector2D& delta, CWindow* pWindow) {
|
|||
g_pHyprRenderer->damageWindow(PWINDOW);
|
||||
}
|
||||
|
||||
void IHyprLayout::onWindowFocusChange(CWindow* pNewFocus) {
|
||||
void IHyprLayout::onWindowFocusChange(PHLWINDOW pNewFocus) {
|
||||
m_pLastTiledWindow = pNewFocus && !pNewFocus->m_bIsFloating ? pNewFocus : m_pLastTiledWindow;
|
||||
}
|
||||
|
||||
CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
|
||||
PHLWINDOW IHyprLayout::getNextWindowCandidate(PHLWINDOW pWindow) {
|
||||
// although we don't expect nullptrs here, let's verify jic
|
||||
if (!pWindow)
|
||||
return nullptr;
|
||||
|
|
@ -580,17 +580,17 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
|
|||
// find whether there is a floating window below this one
|
||||
for (auto& w : g_pCompositor->m_vWindows) {
|
||||
if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_pWorkspace == pWindow->m_pWorkspace && !w->m_bX11ShouldntFocus &&
|
||||
!w->m_sAdditionalConfigData.noFocus && w.get() != pWindow) {
|
||||
!w->m_sAdditionalConfigData.noFocus && w != pWindow) {
|
||||
if (VECINRECT((pWindow->m_vSize / 2.f + pWindow->m_vPosition), w->m_vPosition.x, w->m_vPosition.y, w->m_vPosition.x + w->m_vSize.x,
|
||||
w->m_vPosition.y + w->m_vSize.y)) {
|
||||
return w.get();
|
||||
return w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// let's try the last tiled window.
|
||||
if (m_pLastTiledWindow && m_pLastTiledWindow->m_pWorkspace == pWindow->m_pWorkspace)
|
||||
return m_pLastTiledWindow;
|
||||
if (m_pLastTiledWindow.lock() && m_pLastTiledWindow.lock()->m_pWorkspace == pWindow->m_pWorkspace)
|
||||
return m_pLastTiledWindow.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);
|
||||
|
|
@ -600,8 +600,8 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
|
|||
// if not, floating window
|
||||
for (auto& w : g_pCompositor->m_vWindows) {
|
||||
if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_pWorkspace == pWindow->m_pWorkspace && !w->m_bX11ShouldntFocus &&
|
||||
!w->m_sAdditionalConfigData.noFocus && w.get() != pWindow)
|
||||
return w.get();
|
||||
!w->m_sAdditionalConfigData.noFocus && w != pWindow)
|
||||
return w;
|
||||
}
|
||||
|
||||
// if there is no candidate, too bad
|
||||
|
|
@ -624,27 +624,27 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
|
|||
return pWindowCandidate;
|
||||
}
|
||||
|
||||
bool IHyprLayout::isWindowReachable(CWindow* pWindow) {
|
||||
return pWindow && (!pWindow->isHidden() || pWindow->m_sGroupData.pNextWindow);
|
||||
bool IHyprLayout::isWindowReachable(PHLWINDOW pWindow) {
|
||||
return pWindow && (!pWindow->isHidden() || pWindow->m_sGroupData.pNextWindow.lock());
|
||||
}
|
||||
|
||||
void IHyprLayout::bringWindowToTop(CWindow* pWindow) {
|
||||
void IHyprLayout::bringWindowToTop(PHLWINDOW pWindow) {
|
||||
if (pWindow == nullptr)
|
||||
return;
|
||||
|
||||
if (pWindow->isHidden() && pWindow->m_sGroupData.pNextWindow) {
|
||||
if (pWindow->isHidden() && pWindow->m_sGroupData.pNextWindow.lock()) {
|
||||
// grouped, change the current to this window
|
||||
pWindow->setGroupCurrent(pWindow);
|
||||
}
|
||||
}
|
||||
|
||||
void IHyprLayout::requestFocusForWindow(CWindow* pWindow) {
|
||||
void IHyprLayout::requestFocusForWindow(PHLWINDOW pWindow) {
|
||||
bringWindowToTop(pWindow);
|
||||
g_pCompositor->focusWindow(pWindow);
|
||||
g_pCompositor->warpCursorTo(pWindow->middle());
|
||||
}
|
||||
|
||||
Vector2D IHyprLayout::predictSizeForNewWindowFloating(CWindow* pWindow) { // get all rules, see if we have any size overrides.
|
||||
Vector2D IHyprLayout::predictSizeForNewWindowFloating(PHLWINDOW pWindow) { // get all rules, see if we have any size overrides.
|
||||
Vector2D sizeOverride = {};
|
||||
if (g_pCompositor->m_pLastMonitor) {
|
||||
for (auto& r : g_pConfigManager->getMatchingRules(pWindow, true, true)) {
|
||||
|
|
@ -674,7 +674,7 @@ Vector2D IHyprLayout::predictSizeForNewWindowFloating(CWindow* pWindow) { // get
|
|||
return sizeOverride;
|
||||
}
|
||||
|
||||
Vector2D IHyprLayout::predictSizeForNewWindow(CWindow* pWindow) {
|
||||
Vector2D IHyprLayout::predictSizeForNewWindow(PHLWINDOW pWindow) {
|
||||
bool shouldBeFloated = g_pXWaylandManager->shouldBeFloated(pWindow, true);
|
||||
|
||||
if (!shouldBeFloated) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct SWindowRenderLayoutHints {
|
|||
};
|
||||
|
||||
struct SLayoutMessageHeader {
|
||||
CWindow* pWindow = nullptr;
|
||||
PHLWINDOW pWindow;
|
||||
};
|
||||
|
||||
enum eFullscreenMode : int8_t;
|
||||
|
|
@ -44,21 +44,21 @@ class IHyprLayout {
|
|||
The layout HAS TO set the goal pos and size (anim mgr will use it)
|
||||
If !animationinprogress, then the anim mgr will not apply an anim.
|
||||
*/
|
||||
virtual void onWindowCreated(CWindow*, eDirection direction = DIRECTION_DEFAULT);
|
||||
virtual void onWindowCreatedTiling(CWindow*, eDirection direction = DIRECTION_DEFAULT) = 0;
|
||||
virtual void onWindowCreatedFloating(CWindow*);
|
||||
virtual void onWindowCreated(PHLWINDOW, eDirection direction = DIRECTION_DEFAULT);
|
||||
virtual void onWindowCreatedTiling(PHLWINDOW, eDirection direction = DIRECTION_DEFAULT) = 0;
|
||||
virtual void onWindowCreatedFloating(PHLWINDOW);
|
||||
|
||||
/*
|
||||
Return tiled status
|
||||
*/
|
||||
virtual bool isWindowTiled(CWindow*) = 0;
|
||||
virtual bool isWindowTiled(PHLWINDOW) = 0;
|
||||
|
||||
/*
|
||||
Called when a window is removed (unmapped)
|
||||
*/
|
||||
virtual void onWindowRemoved(CWindow*);
|
||||
virtual void onWindowRemovedTiling(CWindow*) = 0;
|
||||
virtual void onWindowRemovedFloating(CWindow*);
|
||||
virtual void onWindowRemoved(PHLWINDOW);
|
||||
virtual void onWindowRemovedTiling(PHLWINDOW) = 0;
|
||||
virtual void onWindowRemovedFloating(PHLWINDOW);
|
||||
/*
|
||||
Called when the monitor requires a layout recalculation
|
||||
this usually means reserved area changes
|
||||
|
|
@ -69,12 +69,12 @@ class IHyprLayout {
|
|||
Called when the compositor requests a window
|
||||
to be recalculated, e.g. when pseudo is toggled.
|
||||
*/
|
||||
virtual void recalculateWindow(CWindow*) = 0;
|
||||
virtual void recalculateWindow(PHLWINDOW) = 0;
|
||||
|
||||
/*
|
||||
Called when a window is requested to be floated
|
||||
*/
|
||||
virtual void changeWindowFloatingMode(CWindow*);
|
||||
virtual void changeWindowFloatingMode(PHLWINDOW);
|
||||
/*
|
||||
Called when a window is clicked on, beginning a drag
|
||||
this might be a resize, move, whatever the layout defines it
|
||||
|
|
@ -86,13 +86,13 @@ class IHyprLayout {
|
|||
Vector2D holds pixel values
|
||||
Optional pWindow for a specific window
|
||||
*/
|
||||
virtual void resizeActiveWindow(const Vector2D&, eRectCorner corner = CORNER_NONE, CWindow* pWindow = nullptr) = 0;
|
||||
virtual void resizeActiveWindow(const Vector2D&, eRectCorner corner = CORNER_NONE, PHLWINDOW pWindow = nullptr) = 0;
|
||||
/*
|
||||
Called when a user requests a move of the current window by a vec
|
||||
Vector2D holds pixel values
|
||||
Optional pWindow for a specific window
|
||||
*/
|
||||
virtual void moveActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
||||
virtual void moveActiveWindow(const Vector2D&, PHLWINDOW pWindow = nullptr);
|
||||
/*
|
||||
Called when a window is ended being dragged
|
||||
(mouse up)
|
||||
|
|
@ -110,7 +110,7 @@ class IHyprLayout {
|
|||
The layout sets all the fullscreen flags.
|
||||
It can either accept or ignore.
|
||||
*/
|
||||
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool) = 0;
|
||||
virtual void fullscreenRequestForWindow(PHLWINDOW, eFullscreenMode, bool) = 0;
|
||||
|
||||
/*
|
||||
Called when a dispatcher requests a custom message
|
||||
|
|
@ -124,25 +124,25 @@ class IHyprLayout {
|
|||
Called when the renderer requests any special draw flags for
|
||||
a specific window, e.g. border color for groups.
|
||||
*/
|
||||
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*) = 0;
|
||||
virtual SWindowRenderLayoutHints requestRenderHints(PHLWINDOW) = 0;
|
||||
|
||||
/*
|
||||
Called when the user requests two windows to be swapped places.
|
||||
The layout is free to ignore.
|
||||
*/
|
||||
virtual void switchWindows(CWindow*, CWindow*) = 0;
|
||||
virtual void switchWindows(PHLWINDOW, PHLWINDOW) = 0;
|
||||
|
||||
/*
|
||||
Called when the user requests a window move in a direction.
|
||||
The layout is free to ignore.
|
||||
*/
|
||||
virtual void moveWindowTo(CWindow*, const std::string& direction, bool silent = false) = 0;
|
||||
virtual void moveWindowTo(PHLWINDOW, const std::string& direction, bool silent = false) = 0;
|
||||
|
||||
/*
|
||||
Called when the user requests to change the splitratio by or to X
|
||||
on a window
|
||||
*/
|
||||
virtual void alterSplitRatio(CWindow*, float, bool exact = false) = 0;
|
||||
virtual void alterSplitRatio(PHLWINDOW, float, bool exact = false) = 0;
|
||||
|
||||
/*
|
||||
Called when something wants the current layout's name
|
||||
|
|
@ -152,36 +152,36 @@ class IHyprLayout {
|
|||
/*
|
||||
Called for getting the next candidate for a focus
|
||||
*/
|
||||
virtual CWindow* getNextWindowCandidate(CWindow*);
|
||||
virtual PHLWINDOW getNextWindowCandidate(PHLWINDOW);
|
||||
|
||||
/*
|
||||
Internal: called when window focus changes
|
||||
*/
|
||||
virtual void onWindowFocusChange(CWindow*);
|
||||
virtual void onWindowFocusChange(PHLWINDOW);
|
||||
|
||||
/*
|
||||
Called for replacing any data a layout has for a new window
|
||||
*/
|
||||
virtual void replaceWindowDataWith(CWindow* from, CWindow* to) = 0;
|
||||
virtual void replaceWindowDataWith(PHLWINDOW from, PHLWINDOW to) = 0;
|
||||
|
||||
/*
|
||||
Determines if a window can be focused. If hidden this usually means the window is part of a group.
|
||||
*/
|
||||
virtual bool isWindowReachable(CWindow*);
|
||||
virtual bool isWindowReachable(PHLWINDOW);
|
||||
|
||||
/*
|
||||
Called before an attempt is made to focus a window.
|
||||
Brings the window to the top of any groups and ensures it is not hidden.
|
||||
If the window is unmapped following this call, the focus attempt will fail.
|
||||
*/
|
||||
virtual void bringWindowToTop(CWindow*);
|
||||
virtual void bringWindowToTop(PHLWINDOW);
|
||||
|
||||
/*
|
||||
Called via the foreign toplevel activation protocol.
|
||||
Focuses a window, bringing it to the top of its group if applicable.
|
||||
May be ignored.
|
||||
*/
|
||||
virtual void requestFocusForWindow(CWindow*);
|
||||
virtual void requestFocusForWindow(PHLWINDOW);
|
||||
|
||||
/*
|
||||
Called to predict the size of a newly opened window to send it a configure.
|
||||
|
|
@ -192,17 +192,17 @@ class IHyprLayout {
|
|||
/*
|
||||
Prefer not overriding, use predictSizeForNewWindowTiled.
|
||||
*/
|
||||
virtual Vector2D predictSizeForNewWindow(CWindow* pWindow);
|
||||
virtual Vector2D predictSizeForNewWindowFloating(CWindow* pWindow);
|
||||
virtual Vector2D predictSizeForNewWindow(PHLWINDOW pWindow);
|
||||
virtual Vector2D predictSizeForNewWindowFloating(PHLWINDOW pWindow);
|
||||
|
||||
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_iMouseMoveEventCount;
|
||||
Vector2D m_vBeginDragXY;
|
||||
Vector2D m_vLastDragXY;
|
||||
Vector2D m_vBeginDragPositionXY;
|
||||
Vector2D m_vBeginDragSizeXY;
|
||||
Vector2D m_vDraggingWindowOriginalFloatSize;
|
||||
eRectCorner m_eGrabbedCorner = CORNER_TOPLEFT;
|
||||
|
||||
CWindow* m_pLastTiledWindow = nullptr;
|
||||
PHLWINDOWREF m_pLastTiledWindow;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
#include <ranges>
|
||||
#include "../config/ConfigValue.hpp"
|
||||
|
||||
SMasterNodeData* CHyprMasterLayout::getNodeFromWindow(CWindow* pWindow) {
|
||||
SMasterNodeData* CHyprMasterLayout::getNodeFromWindow(PHLWINDOW pWindow) {
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
if (nd.pWindow == pWindow)
|
||||
if (nd.pWindow.lock() == pWindow)
|
||||
return &nd;
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ SMasterNodeData* CHyprMasterLayout::getMasterNodeOnWorkspace(const int& ws) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direction) {
|
||||
void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection direction) {
|
||||
if (pWindow->m_bIsFloating)
|
||||
return;
|
||||
|
||||
|
|
@ -91,27 +91,27 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
|
|||
static auto PMFACT = CConfigValue<Hyprlang::FLOAT>("master:mfact");
|
||||
float lastSplitPercent = *PMFACT;
|
||||
|
||||
auto OPENINGON = isWindowTiled(g_pCompositor->m_pLastWindow) && g_pCompositor->m_pLastWindow->m_pWorkspace == pWindow->m_pWorkspace ?
|
||||
getNodeFromWindow(g_pCompositor->m_pLastWindow) :
|
||||
auto OPENINGON = isWindowTiled(g_pCompositor->m_pLastWindow.lock()) && g_pCompositor->m_pLastWindow.lock()->m_pWorkspace == pWindow->m_pWorkspace ?
|
||||
getNodeFromWindow(g_pCompositor->m_pLastWindow.lock()) :
|
||||
getMasterNodeOnWorkspace(pWindow->workspaceID());
|
||||
|
||||
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
|
||||
|
||||
if (g_pInputManager->m_bWasDraggingWindow && OPENINGON) {
|
||||
if (OPENINGON->pWindow->checkInputOnDecos(INPUT_TYPE_DRAG_END, MOUSECOORDS, pWindow))
|
||||
if (OPENINGON->pWindow.lock()->checkInputOnDecos(INPUT_TYPE_DRAG_END, MOUSECOORDS, pWindow))
|
||||
return;
|
||||
}
|
||||
|
||||
// if it's a group, add the window
|
||||
if (OPENINGON && OPENINGON != PNODE && OPENINGON->pWindow->m_sGroupData.pNextWindow // target is group
|
||||
&& pWindow->canBeGroupedInto(OPENINGON->pWindow)) {
|
||||
if (OPENINGON && OPENINGON != PNODE && OPENINGON->pWindow.lock()->m_sGroupData.pNextWindow.lock() // target is group
|
||||
&& pWindow->canBeGroupedInto(OPENINGON->pWindow.lock())) {
|
||||
|
||||
m_lMasterNodesData.remove(*PNODE);
|
||||
|
||||
static auto USECURRPOS = CConfigValue<Hyprlang::INT>("group:insert_after_current");
|
||||
(*USECURRPOS ? OPENINGON->pWindow : OPENINGON->pWindow->getGroupTail())->insertWindowToGroup(pWindow);
|
||||
(*USECURRPOS ? OPENINGON->pWindow.lock() : OPENINGON->pWindow.lock()->getGroupTail())->insertWindowToGroup(pWindow);
|
||||
|
||||
OPENINGON->pWindow->setGroupCurrent(pWindow);
|
||||
OPENINGON->pWindow.lock()->setGroupCurrent(pWindow);
|
||||
pWindow->applyGroupRules();
|
||||
pWindow->updateWindowDecos();
|
||||
recalculateWindow(pWindow);
|
||||
|
|
@ -135,17 +135,17 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
|
|||
for (auto it = m_lMasterNodesData.begin(); it != m_lMasterNodesData.end(); ++it) {
|
||||
if (it->workspaceID != pWindow->workspaceID())
|
||||
continue;
|
||||
const CBox box = it->pWindow->getWindowIdealBoundingBoxIgnoreReserved();
|
||||
const CBox box = it->pWindow.lock()->getWindowIdealBoundingBoxIgnoreReserved();
|
||||
if (box.containsPoint(MOUSECOORDS)) {
|
||||
switch (orientation) {
|
||||
case ORIENTATION_LEFT:
|
||||
case ORIENTATION_RIGHT:
|
||||
if (MOUSECOORDS.y > it->pWindow->middle().y)
|
||||
if (MOUSECOORDS.y > it->pWindow.lock()->middle().y)
|
||||
++it;
|
||||
break;
|
||||
case ORIENTATION_TOP:
|
||||
case ORIENTATION_BOTTOM:
|
||||
if (MOUSECOORDS.x > it->pWindow->middle().x)
|
||||
if (MOUSECOORDS.x > it->pWindow.lock()->middle().x)
|
||||
++it;
|
||||
break;
|
||||
case ORIENTATION_CENTER: break;
|
||||
|
|
@ -163,19 +163,19 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
|
|||
switch (orientation) {
|
||||
case ORIENTATION_LEFT:
|
||||
case ORIENTATION_CENTER:
|
||||
if (MOUSECOORDS.x < nd.pWindow->middle().x)
|
||||
if (MOUSECOORDS.x < nd.pWindow.lock()->middle().x)
|
||||
forceDropAsMaster = true;
|
||||
break;
|
||||
case ORIENTATION_RIGHT:
|
||||
if (MOUSECOORDS.x > nd.pWindow->middle().x)
|
||||
if (MOUSECOORDS.x > nd.pWindow.lock()->middle().x)
|
||||
forceDropAsMaster = true;
|
||||
break;
|
||||
case ORIENTATION_TOP:
|
||||
if (MOUSECOORDS.y < nd.pWindow->middle().y)
|
||||
if (MOUSECOORDS.y < nd.pWindow.lock()->middle().y)
|
||||
forceDropAsMaster = true;
|
||||
break;
|
||||
case ORIENTATION_BOTTOM:
|
||||
if (MOUSECOORDS.y > nd.pWindow->middle().y)
|
||||
if (MOUSECOORDS.y > nd.pWindow.lock()->middle().y)
|
||||
forceDropAsMaster = true;
|
||||
break;
|
||||
default: UNREACHABLE();
|
||||
|
|
@ -226,7 +226,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
|
|||
recalculateMonitor(pWindow->m_iMonitorID);
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
||||
void CHyprMasterLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
||||
if (!PNODE)
|
||||
|
|
@ -610,7 +610,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
|||
const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
||||
const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
||||
|
||||
const auto PWINDOW = pNode->pWindow;
|
||||
const auto PWINDOW = pNode->pWindow.lock();
|
||||
// get specific gaps and rules for this workspace,
|
||||
// if user specified them in config
|
||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(PWINDOW->m_pWorkspace);
|
||||
|
|
@ -630,7 +630,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
|||
auto gapsIn = WORKSPACERULE.gapsIn.value_or(*PGAPSIN);
|
||||
auto gapsOut = WORKSPACERULE.gapsOut.value_or(*PGAPSOUT);
|
||||
|
||||
if (!g_pCompositor->windowValidMapped(PWINDOW)) {
|
||||
if (!validMapped(PWINDOW)) {
|
||||
Debug::log(ERR, "Node {} holding invalid {}!!", pNode, PWINDOW);
|
||||
return;
|
||||
}
|
||||
|
|
@ -704,14 +704,14 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
|||
PWINDOW->updateWindowDecos();
|
||||
}
|
||||
|
||||
bool CHyprMasterLayout::isWindowTiled(CWindow* pWindow) {
|
||||
bool CHyprMasterLayout::isWindowTiled(PHLWINDOW pWindow) {
|
||||
return getNodeFromWindow(pWindow) != nullptr;
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorner corner, CWindow* pWindow) {
|
||||
const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_pLastWindow;
|
||||
void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorner corner, PHLWINDOW pWindow) {
|
||||
const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_pLastWindow.lock();
|
||||
|
||||
if (!g_pCompositor->windowValidMapped(PWINDOW))
|
||||
if (!validMapped(PWINDOW))
|
||||
return;
|
||||
|
||||
const auto PNODE = getNodeFromWindow(PWINDOW);
|
||||
|
|
@ -850,8 +850,8 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
|||
m_bForceWarps = false;
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreenMode fullscreenMode, bool on) {
|
||||
if (!g_pCompositor->windowValidMapped(pWindow))
|
||||
void CHyprMasterLayout::fullscreenRequestForWindow(PHLWINDOW pWindow, eFullscreenMode fullscreenMode, bool on) {
|
||||
if (!validMapped(pWindow))
|
||||
return;
|
||||
|
||||
if (on == pWindow->m_bIsFullscreen)
|
||||
|
|
@ -932,7 +932,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
|
|||
recalculateMonitor(PMONITOR->ID);
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::recalculateWindow(CWindow* pWindow) {
|
||||
void CHyprMasterLayout::recalculateWindow(PHLWINDOW pWindow) {
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
||||
if (!PNODE)
|
||||
|
|
@ -941,7 +941,7 @@ void CHyprMasterLayout::recalculateWindow(CWindow* pWindow) {
|
|||
recalculateMonitor(pWindow->m_iMonitorID);
|
||||
}
|
||||
|
||||
SWindowRenderLayoutHints CHyprMasterLayout::requestRenderHints(CWindow* pWindow) {
|
||||
SWindowRenderLayoutHints CHyprMasterLayout::requestRenderHints(PHLWINDOW pWindow) {
|
||||
// window should be valid, insallah
|
||||
|
||||
SWindowRenderLayoutHints hints;
|
||||
|
|
@ -949,7 +949,7 @@ SWindowRenderLayoutHints CHyprMasterLayout::requestRenderHints(CWindow* pWindow)
|
|||
return hints; // master doesnt have any hints
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::moveWindowTo(CWindow* pWindow, const std::string& dir, bool silent) {
|
||||
void CHyprMasterLayout::moveWindowTo(PHLWINDOW pWindow, const std::string& dir, bool silent) {
|
||||
if (!isDirection(dir))
|
||||
return;
|
||||
|
||||
|
|
@ -978,7 +978,7 @@ void CHyprMasterLayout::moveWindowTo(CWindow* pWindow, const std::string& dir, b
|
|||
}
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
||||
void CHyprMasterLayout::switchWindows(PHLWINDOW pWindow, PHLWINDOW pWindow2) {
|
||||
// windows should be valid, insallah
|
||||
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
|
@ -1007,7 +1007,7 @@ void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
|||
g_pHyprRenderer->damageWindow(pWindow2);
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::alterSplitRatio(CWindow* pWindow, float ratio, bool exact) {
|
||||
void CHyprMasterLayout::alterSplitRatio(PHLWINDOW pWindow, float ratio, bool exact) {
|
||||
// window should be valid, insallah
|
||||
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
|
@ -1023,7 +1023,7 @@ void CHyprMasterLayout::alterSplitRatio(CWindow* pWindow, float ratio, bool exac
|
|||
recalculateMonitor(pWindow->m_iMonitorID);
|
||||
}
|
||||
|
||||
CWindow* CHyprMasterLayout::getNextWindow(CWindow* pWindow, bool next) {
|
||||
PHLWINDOW CHyprMasterLayout::getNextWindow(PHLWINDOW pWindow, bool next) {
|
||||
if (!isWindowTiled(pWindow))
|
||||
return nullptr;
|
||||
|
||||
|
|
@ -1042,12 +1042,12 @@ CWindow* CHyprMasterLayout::getNextWindow(CWindow* pWindow, bool next) {
|
|||
CANDIDATE =
|
||||
std::find_if(nodes.begin(), nodes.end(), [&](const auto& other) { return other != *PNODE && ISMASTER != other.isMaster && other.workspaceID == PNODE->workspaceID; });
|
||||
|
||||
return CANDIDATE == nodes.end() ? nullptr : CANDIDATE->pWindow;
|
||||
return CANDIDATE == nodes.end() ? nullptr : CANDIDATE->pWindow.lock();
|
||||
}
|
||||
|
||||
std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::string message) {
|
||||
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
|
||||
if (!g_pCompositor->windowValidMapped(PWINDOWTOCHANGETO))
|
||||
auto switchToWindow = [&](PHLWINDOW PWINDOWTOCHANGETO) {
|
||||
if (!validMapped(PWINDOWTOCHANGETO))
|
||||
return;
|
||||
|
||||
if (header.pWindow->m_bIsFullscreen) {
|
||||
|
|
@ -1065,7 +1065,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
|
||||
g_pInputManager->m_pForcedFocus = PWINDOWTOCHANGETO;
|
||||
g_pInputManager->simulateMouseMovement();
|
||||
g_pInputManager->m_pForcedFocus = nullptr;
|
||||
g_pInputManager->m_pForcedFocus.reset();
|
||||
};
|
||||
|
||||
CVarList vars(message, 0, ' ');
|
||||
|
|
@ -1096,9 +1096,9 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
if (!PMASTER)
|
||||
return 0;
|
||||
|
||||
const auto NEWCHILD = PMASTER->pWindow;
|
||||
const auto NEWCHILD = PMASTER->pWindow.lock();
|
||||
|
||||
if (PMASTER->pWindow != PWINDOW) {
|
||||
if (PMASTER->pWindow.lock() != PWINDOW) {
|
||||
const auto NEWMASTER = PWINDOW;
|
||||
const bool newFocusToChild = vars.size() >= 2 && vars[1] == "child";
|
||||
switchWindows(NEWMASTER, NEWCHILD);
|
||||
|
|
@ -1107,7 +1107,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
} else {
|
||||
for (auto& n : m_lMasterNodesData) {
|
||||
if (n.workspaceID == PMASTER->workspaceID && !n.isMaster) {
|
||||
const auto NEWMASTER = n.pWindow;
|
||||
const auto NEWMASTER = n.pWindow.lock();
|
||||
switchWindows(NEWMASTER, NEWCHILD);
|
||||
const bool newFocusToMaster = vars.size() >= 2 && vars[1] == "master";
|
||||
const auto NEWFOCUS = newFocusToMaster ? NEWMASTER : NEWCHILD;
|
||||
|
|
@ -1134,15 +1134,15 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
if (!PMASTER)
|
||||
return 0;
|
||||
|
||||
if (PMASTER->pWindow != PWINDOW) {
|
||||
switchToWindow(PMASTER->pWindow);
|
||||
if (PMASTER->pWindow.lock() != PWINDOW) {
|
||||
switchToWindow(PMASTER->pWindow.lock());
|
||||
} else if (vars.size() >= 2 && vars[1] == "master") {
|
||||
return 0;
|
||||
} else {
|
||||
// if master is focused keep master focused (don't do anything)
|
||||
for (auto& n : m_lMasterNodesData) {
|
||||
if (n.workspaceID == PMASTER->workspaceID && !n.isMaster) {
|
||||
switchToWindow(n.pWindow);
|
||||
switchToWindow(n.pWindow.lock());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1166,7 +1166,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
const auto PPREVWINDOW = getNextWindow(PWINDOW, false);
|
||||
switchToWindow(PPREVWINDOW);
|
||||
} else if (command == "swapnext") {
|
||||
if (!g_pCompositor->windowValidMapped(header.pWindow))
|
||||
if (!validMapped(header.pWindow))
|
||||
return 0;
|
||||
|
||||
if (header.pWindow->m_bIsFloating) {
|
||||
|
|
@ -1182,7 +1182,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
switchToWindow(header.pWindow);
|
||||
}
|
||||
} else if (command == "swapprev") {
|
||||
if (!g_pCompositor->windowValidMapped(header.pWindow))
|
||||
if (!validMapped(header.pWindow))
|
||||
return 0;
|
||||
|
||||
if (header.pWindow->m_bIsFloating) {
|
||||
|
|
@ -1198,7 +1198,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
switchToWindow(header.pWindow);
|
||||
}
|
||||
} else if (command == "addmaster") {
|
||||
if (!g_pCompositor->windowValidMapped(header.pWindow))
|
||||
if (!validMapped(header.pWindow))
|
||||
return 0;
|
||||
|
||||
if (header.pWindow->m_bIsFloating)
|
||||
|
|
@ -1230,7 +1230,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
|
||||
} else if (command == "removemaster") {
|
||||
|
||||
if (!g_pCompositor->windowValidMapped(header.pWindow))
|
||||
if (!validMapped(header.pWindow))
|
||||
return 0;
|
||||
|
||||
if (header.pWindow->m_bIsFloating)
|
||||
|
|
@ -1308,7 +1308,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
nd.isMaster = true;
|
||||
const auto NEWMASTERIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), nd);
|
||||
m_lMasterNodesData.splice(OLDMASTERIT, m_lMasterNodesData, NEWMASTERIT);
|
||||
switchToWindow(nd.pWindow);
|
||||
switchToWindow(nd.pWindow.lock());
|
||||
OLDMASTER->isMaster = false;
|
||||
m_lMasterNodesData.splice(m_lMasterNodesData.end(), m_lMasterNodesData, OLDMASTERIT);
|
||||
break;
|
||||
|
|
@ -1334,7 +1334,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
nd.isMaster = true;
|
||||
const auto NEWMASTERIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), nd);
|
||||
m_lMasterNodesData.splice(OLDMASTERIT, m_lMasterNodesData, NEWMASTERIT);
|
||||
switchToWindow(nd.pWindow);
|
||||
switchToWindow(nd.pWindow.lock());
|
||||
OLDMASTER->isMaster = false;
|
||||
m_lMasterNodesData.splice(m_lMasterNodesData.begin(), m_lMasterNodesData, OLDMASTERIT);
|
||||
break;
|
||||
|
|
@ -1428,7 +1428,7 @@ eOrientation CHyprMasterLayout::getDynamicOrientation(PHLWORKSPACE pWorkspace) {
|
|||
return orientation;
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::replaceWindowDataWith(CWindow* from, CWindow* to) {
|
||||
void CHyprMasterLayout::replaceWindowDataWith(PHLWINDOW from, PHLWINDOW to) {
|
||||
const auto PNODE = getNodeFromWindow(from);
|
||||
|
||||
if (!PNODE)
|
||||
|
|
@ -1471,7 +1471,7 @@ void CHyprMasterLayout::onEnable() {
|
|||
if (w->m_bIsFloating || !w->m_bIsMapped || w->isHidden())
|
||||
continue;
|
||||
|
||||
onWindowCreatedTiling(w.get());
|
||||
onWindowCreatedTiling(w);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,23 +20,23 @@ enum eOrientation : uint8_t {
|
|||
};
|
||||
|
||||
struct SMasterNodeData {
|
||||
bool isMaster = false;
|
||||
float percMaster = 0.5f;
|
||||
bool isMaster = false;
|
||||
float percMaster = 0.5f;
|
||||
|
||||
CWindow* pWindow = nullptr;
|
||||
PHLWINDOWREF pWindow;
|
||||
|
||||
Vector2D position;
|
||||
Vector2D size;
|
||||
Vector2D position;
|
||||
Vector2D size;
|
||||
|
||||
float percSize = 1.f; // size multiplier for resizing children
|
||||
float percSize = 1.f; // size multiplier for resizing children
|
||||
|
||||
int workspaceID = -1;
|
||||
int workspaceID = -1;
|
||||
|
||||
bool ignoreFullscreenChecks = false;
|
||||
bool ignoreFullscreenChecks = false;
|
||||
|
||||
//
|
||||
bool operator==(const SMasterNodeData& rhs) const {
|
||||
return pWindow == rhs.pWindow;
|
||||
return pWindow.lock() == rhs.pWindow.lock();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -52,20 +52,20 @@ struct SMasterWorkspaceData {
|
|||
|
||||
class CHyprMasterLayout : public IHyprLayout {
|
||||
public:
|
||||
virtual void onWindowCreatedTiling(CWindow*, eDirection direction = DIRECTION_DEFAULT);
|
||||
virtual void onWindowRemovedTiling(CWindow*);
|
||||
virtual bool isWindowTiled(CWindow*);
|
||||
virtual void onWindowCreatedTiling(PHLWINDOW, eDirection direction = DIRECTION_DEFAULT);
|
||||
virtual void onWindowRemovedTiling(PHLWINDOW);
|
||||
virtual bool isWindowTiled(PHLWINDOW);
|
||||
virtual void recalculateMonitor(const int&);
|
||||
virtual void recalculateWindow(CWindow*);
|
||||
virtual void resizeActiveWindow(const Vector2D&, eRectCorner corner = CORNER_NONE, CWindow* pWindow = nullptr);
|
||||
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
|
||||
virtual void recalculateWindow(PHLWINDOW);
|
||||
virtual void resizeActiveWindow(const Vector2D&, eRectCorner corner = CORNER_NONE, PHLWINDOW pWindow = nullptr);
|
||||
virtual void fullscreenRequestForWindow(PHLWINDOW, eFullscreenMode, bool);
|
||||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
||||
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
||||
virtual void switchWindows(CWindow*, CWindow*);
|
||||
virtual void moveWindowTo(CWindow*, const std::string& dir, bool silent);
|
||||
virtual void alterSplitRatio(CWindow*, float, bool);
|
||||
virtual SWindowRenderLayoutHints requestRenderHints(PHLWINDOW);
|
||||
virtual void switchWindows(PHLWINDOW, PHLWINDOW);
|
||||
virtual void moveWindowTo(PHLWINDOW, const std::string& dir, bool silent);
|
||||
virtual void alterSplitRatio(PHLWINDOW, float, bool);
|
||||
virtual std::string getLayoutName();
|
||||
virtual void replaceWindowDataWith(CWindow* from, CWindow* to);
|
||||
virtual void replaceWindowDataWith(PHLWINDOW from, PHLWINDOW to);
|
||||
virtual Vector2D predictSizeForNewWindowTiled();
|
||||
|
||||
virtual void onEnable();
|
||||
|
|
@ -83,11 +83,11 @@ class CHyprMasterLayout : public IHyprLayout {
|
|||
eOrientation getDynamicOrientation(PHLWORKSPACE);
|
||||
int getNodesOnWorkspace(const int&);
|
||||
void applyNodeDataToWindow(SMasterNodeData*);
|
||||
SMasterNodeData* getNodeFromWindow(CWindow*);
|
||||
SMasterNodeData* getNodeFromWindow(PHLWINDOW);
|
||||
SMasterNodeData* getMasterNodeOnWorkspace(const int&);
|
||||
SMasterWorkspaceData* getMasterWorkspaceData(const int&);
|
||||
void calculateWorkspace(PHLWORKSPACE);
|
||||
CWindow* getNextWindow(CWindow*, bool);
|
||||
PHLWINDOW getNextWindow(PHLWINDOW, bool);
|
||||
int getMastersOnWorkspace(const int&);
|
||||
|
||||
friend struct SMasterNodeData;
|
||||
|
|
@ -104,8 +104,8 @@ struct std::formatter<SMasterNodeData*, CharT> : std::formatter<CharT> {
|
|||
std::format_to(out, "[Node {:x}: workspace: {}, pos: {:j2}, size: {:j2}", (uintptr_t)node, node->workspaceID, node->position, node->size);
|
||||
if (node->isMaster)
|
||||
std::format_to(out, ", master");
|
||||
if (node->pWindow)
|
||||
std::format_to(out, ", window: {:x}", node->pWindow);
|
||||
if (!node->pWindow.expired())
|
||||
std::format_to(out, ", window: {:x}", node->pWindow.lock());
|
||||
return std::format_to(out, "]");
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue