mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 19:05:58 +01:00
master: fix workspace orientation not being restored after workspace rule no longer applies (#5463)
This commit is contained in:
parent
ff114cf6f9
commit
e80bccad51
2 changed files with 35 additions and 37 deletions
|
@ -44,20 +44,14 @@ SMasterWorkspaceData* CHyprMasterLayout::getMasterWorkspaceData(const int& ws) {
|
||||||
const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
|
const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
|
||||||
PWORKSPACEDATA->workspaceID = ws;
|
PWORKSPACEDATA->workspaceID = ws;
|
||||||
static auto PORIENTATION = CConfigValue<std::string>("master:orientation");
|
static auto PORIENTATION = CConfigValue<std::string>("master:orientation");
|
||||||
const auto layoutoptsForWs = g_pConfigManager->getWorkspaceRuleFor(g_pCompositor->getWorkspaceByID(ws)).layoutopts;
|
|
||||||
|
|
||||||
std::string orientationForWs = *PORIENTATION;
|
if (*PORIENTATION == "top")
|
||||||
|
|
||||||
if (layoutoptsForWs.contains("orientation"))
|
|
||||||
orientationForWs = layoutoptsForWs.at("orientation");
|
|
||||||
|
|
||||||
if (orientationForWs == "top")
|
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
||||||
else if (orientationForWs == "right")
|
else if (*PORIENTATION == "right")
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
|
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
|
||||||
else if (orientationForWs == "bottom")
|
else if (*PORIENTATION == "bottom")
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
||||||
else if (orientationForWs == "center")
|
else if (*PORIENTATION == "center")
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_CENTER;
|
PWORKSPACEDATA->orientation = ORIENTATION_CENTER;
|
||||||
else
|
else
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
||||||
|
@ -130,10 +124,9 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
|
||||||
|
|
||||||
pWindow->applyGroupRules();
|
pWindow->applyGroupRules();
|
||||||
|
|
||||||
static auto PDROPATCURSOR = CConfigValue<Hyprlang::INT>("master:drop_at_cursor");
|
static auto PDROPATCURSOR = CConfigValue<Hyprlang::INT>("master:drop_at_cursor");
|
||||||
const auto PWORKSPACEDATA = getMasterWorkspaceData(pWindow->workspaceID());
|
eOrientation orientation = getDynamicOrientation(pWindow->m_pWorkspace);
|
||||||
eOrientation orientation = PWORKSPACEDATA->orientation;
|
const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE);
|
||||||
const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE);
|
|
||||||
|
|
||||||
bool forceDropAsMaster = false;
|
bool forceDropAsMaster = false;
|
||||||
// if dragging window to move, drop it at the cursor position instead of bottom/top of stack
|
// if dragging window to move, drop it at the cursor position instead of bottom/top of stack
|
||||||
|
@ -325,31 +318,12 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto PWORKSPACEDATA = getMasterWorkspaceData(pWorkspace->m_iID);
|
const auto PMASTERNODE = getMasterNodeOnWorkspace(pWorkspace->m_iID);
|
||||||
const auto PMASTERNODE = getMasterNodeOnWorkspace(pWorkspace->m_iID);
|
|
||||||
|
|
||||||
if (!PMASTERNODE)
|
if (!PMASTERNODE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// dynamic workspace rules
|
eOrientation orientation = getDynamicOrientation(pWorkspace);
|
||||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(pWorkspace);
|
|
||||||
std::string orientationForWs;
|
|
||||||
|
|
||||||
if (WORKSPACERULE.layoutopts.contains("orientation"))
|
|
||||||
orientationForWs = WORKSPACERULE.layoutopts.at("orientation");
|
|
||||||
|
|
||||||
if (orientationForWs == "top")
|
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
|
||||||
else if (orientationForWs == "right")
|
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
|
|
||||||
else if (orientationForWs == "bottom")
|
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
|
||||||
else if (orientationForWs == "center")
|
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_CENTER;
|
|
||||||
else if (orientationForWs == "left")
|
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
|
||||||
|
|
||||||
eOrientation orientation = PWORKSPACEDATA->orientation;
|
|
||||||
bool centerMasterWindow = false;
|
bool centerMasterWindow = false;
|
||||||
static auto ALWAYSCENTER = CConfigValue<Hyprlang::INT>("master:always_center_master");
|
static auto ALWAYSCENTER = CConfigValue<Hyprlang::INT>("master:always_center_master");
|
||||||
static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("master:smart_resizing");
|
static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("master:smart_resizing");
|
||||||
|
@ -749,11 +723,10 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
const auto PWORKSPACEDATA = getMasterWorkspaceData(PWINDOW->workspaceID());
|
|
||||||
static auto ALWAYSCENTER = CConfigValue<Hyprlang::INT>("master:always_center_master");
|
static auto ALWAYSCENTER = CConfigValue<Hyprlang::INT>("master:always_center_master");
|
||||||
static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("master:smart_resizing");
|
static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("master:smart_resizing");
|
||||||
|
|
||||||
eOrientation orientation = PWORKSPACEDATA->orientation;
|
eOrientation orientation = getDynamicOrientation(pWindow->m_pWorkspace);
|
||||||
bool centered = orientation == ORIENTATION_CENTER && (*ALWAYSCENTER == 1);
|
bool centered = orientation == ORIENTATION_CENTER && (*ALWAYSCENTER == 1);
|
||||||
double delta = 0;
|
double delta = 0;
|
||||||
|
|
||||||
|
@ -1439,6 +1412,30 @@ void CHyprMasterLayout::buildOrientationCycleVectorFromVars(std::vector<eOrienta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eOrientation CHyprMasterLayout::getDynamicOrientation(PHLWORKSPACE pWorkspace) {
|
||||||
|
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(pWorkspace);
|
||||||
|
std::string orientationString;
|
||||||
|
if (WORKSPACERULE.layoutopts.contains("orientation"))
|
||||||
|
orientationString = WORKSPACERULE.layoutopts.at("orientation");
|
||||||
|
|
||||||
|
eOrientation orientation = getMasterWorkspaceData(pWorkspace->m_iID)->orientation;
|
||||||
|
// override if workspace rule is set
|
||||||
|
if (!orientationString.empty()) {
|
||||||
|
if (orientationString == "top")
|
||||||
|
orientation = ORIENTATION_TOP;
|
||||||
|
else if (orientationString == "right")
|
||||||
|
orientation = ORIENTATION_RIGHT;
|
||||||
|
else if (orientationString == "bottom")
|
||||||
|
orientation = ORIENTATION_BOTTOM;
|
||||||
|
else if (orientationString == "center")
|
||||||
|
orientation = ORIENTATION_CENTER;
|
||||||
|
else
|
||||||
|
orientation = ORIENTATION_LEFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return orientation;
|
||||||
|
}
|
||||||
|
|
||||||
void CHyprMasterLayout::replaceWindowDataWith(CWindow* from, CWindow* to) {
|
void CHyprMasterLayout::replaceWindowDataWith(CWindow* from, CWindow* to) {
|
||||||
const auto PNODE = getNodeFromWindow(from);
|
const auto PNODE = getNodeFromWindow(from);
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ class CHyprMasterLayout : public IHyprLayout {
|
||||||
void buildOrientationCycleVectorFromVars(std::vector<eOrientation>& cycle, CVarList& vars);
|
void buildOrientationCycleVectorFromVars(std::vector<eOrientation>& cycle, CVarList& vars);
|
||||||
void buildOrientationCycleVectorFromEOperation(std::vector<eOrientation>& cycle);
|
void buildOrientationCycleVectorFromEOperation(std::vector<eOrientation>& cycle);
|
||||||
void runOrientationCycle(SLayoutMessageHeader& header, CVarList* vars, int next);
|
void runOrientationCycle(SLayoutMessageHeader& header, CVarList* vars, int next);
|
||||||
|
eOrientation getDynamicOrientation(PHLWORKSPACE);
|
||||||
int getNodesOnWorkspace(const int&);
|
int getNodesOnWorkspace(const int&);
|
||||||
void applyNodeDataToWindow(SMasterNodeData*);
|
void applyNodeDataToWindow(SMasterNodeData*);
|
||||||
SMasterNodeData* getNodeFromWindow(CWindow*);
|
SMasterNodeData* getNodeFromWindow(CWindow*);
|
||||||
|
|
Loading…
Reference in a new issue