mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 00:25:57 +01:00
Merge pull request #242 from calebowens/caleb-feature-add-width-multiplier
Added a multiplier for the width to height ratio
This commit is contained in:
commit
7c999fb9f5
2 changed files with 19 additions and 11 deletions
|
@ -70,6 +70,7 @@ void CConfigManager::setDefaultVars() {
|
||||||
configValues["dwindle:force_split"].intValue = 0;
|
configValues["dwindle:force_split"].intValue = 0;
|
||||||
configValues["dwindle:preserve_split"].intValue = 0;
|
configValues["dwindle:preserve_split"].intValue = 0;
|
||||||
configValues["dwindle:special_scale_factor"].floatValue = 0.8f;
|
configValues["dwindle:special_scale_factor"].floatValue = 0.8f;
|
||||||
|
configValues["dwindle:split_width_multiplier"].floatValue = 1.0f;
|
||||||
|
|
||||||
configValues["animations:enabled"].intValue = 1;
|
configValues["animations:enabled"].intValue = 1;
|
||||||
configValues["animations:speed"].floatValue = 7.f;
|
configValues["animations:speed"].floatValue = 7.f;
|
||||||
|
|
|
@ -23,19 +23,21 @@ void SDwindleNodeData::recalcSizePosRecursive() {
|
||||||
|
|
||||||
const auto REVERSESPLITRATIO = 2.f - splitRatio;
|
const auto REVERSESPLITRATIO = 2.f - splitRatio;
|
||||||
|
|
||||||
if (g_pConfigManager->getInt("dwindle:preserve_split") == 0)
|
if (g_pConfigManager->getInt("dwindle:preserve_split") == 0) {
|
||||||
splitTop = size.y > size.x;
|
const auto WIDTHMULTIPLIER = g_pConfigManager->getFloat("dwindle:split_width_multiplier");
|
||||||
|
splitTop = size.y * WIDTHMULTIPLIER > size.x;
|
||||||
|
}
|
||||||
|
|
||||||
const auto SPLITSIDE = !splitTop;
|
const auto SPLITSIDE = !splitTop;
|
||||||
|
|
||||||
if (SPLITSIDE) {
|
if (SPLITSIDE) {
|
||||||
// split sidey
|
// split left/right
|
||||||
children[0]->position = position;
|
children[0]->position = position;
|
||||||
children[0]->size = Vector2D(size.x / 2.f * splitRatio, size.y);
|
children[0]->size = Vector2D(size.x / 2.f * splitRatio, size.y);
|
||||||
children[1]->position = Vector2D(position.x + size.x / 2.f * splitRatio, position.y);
|
children[1]->position = Vector2D(position.x + size.x / 2.f * splitRatio, position.y);
|
||||||
children[1]->size = Vector2D(size.x / 2.f * REVERSESPLITRATIO, size.y);
|
children[1]->size = Vector2D(size.x / 2.f * REVERSESPLITRATIO, size.y);
|
||||||
} else {
|
} else {
|
||||||
// split toppy bottomy
|
// split top/bottom
|
||||||
children[0]->position = position;
|
children[0]->position = position;
|
||||||
children[0]->size = Vector2D(size.x, size.y / 2.f * splitRatio);
|
children[0]->size = Vector2D(size.x, size.y / 2.f * splitRatio);
|
||||||
children[1]->position = Vector2D(position.x, position.y + size.y / 2.f * splitRatio);
|
children[1]->position = Vector2D(position.x, position.y + size.y / 2.f * splitRatio);
|
||||||
|
@ -246,16 +248,19 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
||||||
NEWPARENT->pParent = OPENINGON->pParent;
|
NEWPARENT->pParent = OPENINGON->pParent;
|
||||||
NEWPARENT->isNode = true; // it is a node
|
NEWPARENT->isNode = true; // it is a node
|
||||||
|
|
||||||
|
const auto WIDTHMULTIPLIER = g_pConfigManager->getFloat("dwindle:split_width_multiplier");
|
||||||
|
|
||||||
// if cursor over first child, make it first, etc
|
// if cursor over first child, make it first, etc
|
||||||
const auto SIDEBYSIDE = NEWPARENT->size.x / NEWPARENT->size.y > 1.f;
|
const auto SIDEBYSIDE = NEWPARENT->size.x > NEWPARENT->size.y * WIDTHMULTIPLIER;
|
||||||
NEWPARENT->splitTop = !SIDEBYSIDE;
|
NEWPARENT->splitTop = !SIDEBYSIDE;
|
||||||
|
|
||||||
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
|
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
|
||||||
|
|
||||||
const auto FORCESPLIT = g_pConfigManager->getInt("dwindle:force_split");
|
const auto FORCESPLIT = g_pConfigManager->getInt("dwindle:force_split");
|
||||||
|
|
||||||
if (FORCESPLIT == 0) {
|
if (FORCESPLIT == 0) {
|
||||||
if ((SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y, NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y + NEWPARENT->size.y))
|
if ((SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / WIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y + NEWPARENT->size.y))
|
||||||
|| (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) {
|
|| (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / WIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) {
|
||||||
// we are hovering over the first node, make PNODE first.
|
// we are hovering over the first node, make PNODE first.
|
||||||
NEWPARENT->children[1] = OPENINGON;
|
NEWPARENT->children[1] = OPENINGON;
|
||||||
NEWPARENT->children[0] = PNODE;
|
NEWPARENT->children[0] = PNODE;
|
||||||
|
@ -284,14 +289,16 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the children
|
// Update the children
|
||||||
if (NEWPARENT->size.x > NEWPARENT->size.y) {
|
|
||||||
// split sidey
|
|
||||||
|
if (NEWPARENT->size.x * WIDTHMULTIPLIER > NEWPARENT->size.y) {
|
||||||
|
// split left/right
|
||||||
OPENINGON->position = NEWPARENT->position;
|
OPENINGON->position = NEWPARENT->position;
|
||||||
OPENINGON->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
|
OPENINGON->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
|
||||||
PNODE->position = Vector2D(NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y);
|
PNODE->position = Vector2D(NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y);
|
||||||
PNODE->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
|
PNODE->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
|
||||||
} else {
|
} else {
|
||||||
// split toppy bottomy
|
// split top/bottom
|
||||||
OPENINGON->position = NEWPARENT->position;
|
OPENINGON->position = NEWPARENT->position;
|
||||||
OPENINGON->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f);
|
OPENINGON->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f);
|
||||||
PNODE->position = Vector2D(NEWPARENT->position.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f);
|
PNODE->position = Vector2D(NEWPARENT->position.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f);
|
||||||
|
|
Loading…
Reference in a new issue