mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-16 03:03:40 +01:00
Fix miscalculated gaps
This commit is contained in:
parent
a3c32868cc
commit
fe98ccaf9a
2 changed files with 76 additions and 48 deletions
|
@ -219,10 +219,22 @@ void Hy3Layout::recalculateMonitor(const int& monitor_id) {
|
||||||
} else {
|
} else {
|
||||||
// Vaxry's hack from below, but again
|
// Vaxry's hack from below, but again
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
static const auto* gaps_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue;
|
||||||
|
static const auto* gaps_out = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_out")->intValue;
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
int outer_gaps = -(*gaps_in - *gaps_out);
|
||||||
|
auto gap_pos_offset = Vector2D(outer_gaps, outer_gaps);
|
||||||
|
auto gap_size_offset = Vector2D(outer_gaps * 2, outer_gaps * 2);
|
||||||
|
Debug::log(LOG, "FS gaps: %d", outer_gaps);
|
||||||
|
|
||||||
Hy3Node fakeNode = {
|
Hy3Node fakeNode = {
|
||||||
.data = window,
|
.data = window,
|
||||||
.position = monitor->vecPosition + monitor->vecReservedTopLeft,
|
.position = monitor->vecPosition + monitor->vecReservedTopLeft,
|
||||||
.size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
|
.size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
|
||||||
|
.gap_pos_offset = gap_pos_offset,
|
||||||
|
.gap_size_offset = gap_size_offset,
|
||||||
.workspace_id = window->m_iWorkspaceID,
|
.workspace_id = window->m_iWorkspaceID,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -528,10 +540,22 @@ void Hy3Layout::fullscreenRequestForWindow(
|
||||||
Debug::log(LOG, "vaxry hack");
|
Debug::log(LOG, "vaxry hack");
|
||||||
// Copy of vaxry's massive hack
|
// Copy of vaxry's massive hack
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
static const auto* gaps_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue;
|
||||||
|
static const auto* gaps_out = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_out")->intValue;
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
int outer_gaps = -(*gaps_in - *gaps_out);
|
||||||
|
auto gap_pos_offset = Vector2D(outer_gaps, outer_gaps);
|
||||||
|
auto gap_size_offset = Vector2D(outer_gaps * 2, outer_gaps * 2);
|
||||||
|
Debug::log(LOG, "FS gaps: %d", outer_gaps);
|
||||||
|
|
||||||
Hy3Node fakeNode = {
|
Hy3Node fakeNode = {
|
||||||
.data = window,
|
.data = window,
|
||||||
.position = monitor->vecPosition + monitor->vecReservedTopLeft,
|
.position = monitor->vecPosition + monitor->vecReservedTopLeft,
|
||||||
.size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
|
.size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
|
||||||
|
.gap_pos_offset = gap_pos_offset,
|
||||||
|
.gap_size_offset = gap_size_offset,
|
||||||
.workspace_id = window->m_iWorkspaceID,
|
.workspace_id = window->m_iWorkspaceID,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -790,7 +814,7 @@ Hy3Node* findTabBarAt(Hy3Node& node, Vector2D pos, Hy3Node** focused_node) {
|
||||||
if (node.data.as_group.layout == Hy3GroupLayout::Tabbed
|
if (node.data.as_group.layout == Hy3GroupLayout::Tabbed
|
||||||
&& node.data.as_group.tab_bar != nullptr)
|
&& node.data.as_group.tab_bar != nullptr)
|
||||||
{
|
{
|
||||||
if (pos.y < node.position.y + inset) {
|
if (pos.y < node.position.y + node.gap_pos_offset.y + inset) {
|
||||||
auto& children = node.data.as_group.children;
|
auto& children = node.data.as_group.children;
|
||||||
auto& tab_bar = *node.data.as_group.tab_bar;
|
auto& tab_bar = *node.data.as_group.tab_bar;
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,7 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
|
||||||
Vector2D gap_pos_offset;
|
Vector2D gap_pos_offset;
|
||||||
Vector2D gap_size_offset;
|
Vector2D gap_size_offset;
|
||||||
if (this->parent == nullptr) {
|
if (this->parent == nullptr) {
|
||||||
outer_gaps = *gaps_out - *gaps_in;
|
outer_gaps = -(*gaps_in - *gaps_out);
|
||||||
|
|
||||||
gap_pos_offset = Vector2D(outer_gaps, outer_gaps);
|
gap_pos_offset = Vector2D(outer_gaps, outer_gaps);
|
||||||
gap_size_offset = Vector2D(outer_gaps * 2, outer_gaps * 2);
|
gap_size_offset = Vector2D(outer_gaps * 2, outer_gaps * 2);
|
||||||
|
@ -250,45 +250,6 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
|
||||||
|
|
||||||
auto* group = &this->data.as_group;
|
auto* group = &this->data.as_group;
|
||||||
|
|
||||||
if (group->children.size() == 1 && this->parent != nullptr) {
|
|
||||||
auto child = group->children.front();
|
|
||||||
|
|
||||||
if (child == this) {
|
|
||||||
Debug::log(ERR, "a group (%p) has become its own child", this);
|
|
||||||
errorNotif();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (group->layout) {
|
|
||||||
case Hy3GroupLayout::SplitH:
|
|
||||||
child->position.x = tpos.x;
|
|
||||||
child->size.x = tsize.x - *group_inset;
|
|
||||||
child->position.y = tpos.y;
|
|
||||||
child->size.y = tsize.y;
|
|
||||||
break;
|
|
||||||
case Hy3GroupLayout::SplitV:
|
|
||||||
child->position.y = tpos.y;
|
|
||||||
child->size.y = tsize.y - *group_inset;
|
|
||||||
child->position.x = tpos.x;
|
|
||||||
child->size.x = tsize.x;
|
|
||||||
break;
|
|
||||||
case Hy3GroupLayout::Tabbed:
|
|
||||||
child->position.y = tpos.y + tab_height_offset;
|
|
||||||
child->size.y = tsize.y - tab_height_offset;
|
|
||||||
child->position.x = tpos.x;
|
|
||||||
child->size.x = tsize.x;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
child->gap_pos_offset = gap_pos_offset;
|
|
||||||
child->gap_size_offset = gap_size_offset;
|
|
||||||
|
|
||||||
child->setHidden(this->hidden);
|
|
||||||
|
|
||||||
child->recalcSizePosRecursive(no_animation);
|
|
||||||
this->updateTabBar(no_animation);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int constraint;
|
int constraint;
|
||||||
switch (group->layout) {
|
switch (group->layout) {
|
||||||
case Hy3GroupLayout::SplitH: constraint = tsize.x; break;
|
case Hy3GroupLayout::SplitH: constraint = tsize.x; break;
|
||||||
|
@ -296,6 +257,12 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
|
||||||
case Hy3GroupLayout::Tabbed: break;
|
case Hy3GroupLayout::Tabbed: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (group->layout) {
|
||||||
|
case Hy3GroupLayout::SplitH: constraint -= gap_size_offset.x; break;
|
||||||
|
case Hy3GroupLayout::SplitV: constraint -= gap_size_offset.y; break;
|
||||||
|
case Hy3GroupLayout::Tabbed: break;
|
||||||
|
}
|
||||||
|
|
||||||
double ratio_mul = group->layout != Hy3GroupLayout::Tabbed
|
double ratio_mul = group->layout != Hy3GroupLayout::Tabbed
|
||||||
? group->children.empty() ? 0 : constraint / group->children.size()
|
? group->children.empty() ? 0 : constraint / group->children.size()
|
||||||
: 0;
|
: 0;
|
||||||
|
@ -320,6 +287,25 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
|
||||||
child->position.y = tpos.y;
|
child->position.y = tpos.y;
|
||||||
child->size.y = tsize.y;
|
child->size.y = tsize.y;
|
||||||
child->setHidden(this->hidden);
|
child->setHidden(this->hidden);
|
||||||
|
|
||||||
|
if (group->children.size() == 1) {
|
||||||
|
child->gap_pos_offset = gap_pos_offset;
|
||||||
|
child->gap_size_offset = gap_size_offset;
|
||||||
|
if (this->parent != nullptr) child->gap_size_offset.x += *group_inset;
|
||||||
|
child->size.x += gap_size_offset.x;
|
||||||
|
} else if (child == group->children.front()) {
|
||||||
|
child->gap_pos_offset = gap_pos_offset;
|
||||||
|
child->gap_size_offset = Vector2D(0, gap_size_offset.y);
|
||||||
|
offset += gap_pos_offset.x;
|
||||||
|
} else if (child == group->children.back()) {
|
||||||
|
child->gap_pos_offset = Vector2D(0, gap_pos_offset.y);
|
||||||
|
child->gap_size_offset = gap_size_offset;
|
||||||
|
child->size.x += gap_size_offset.x;
|
||||||
|
} else {
|
||||||
|
child->gap_pos_offset = Vector2D(0, gap_pos_offset.y);
|
||||||
|
child->gap_size_offset = Vector2D(0, gap_size_offset.y);
|
||||||
|
}
|
||||||
|
|
||||||
child->recalcSizePosRecursive(no_animation);
|
child->recalcSizePosRecursive(no_animation);
|
||||||
break;
|
break;
|
||||||
case Hy3GroupLayout::SplitV:
|
case Hy3GroupLayout::SplitV:
|
||||||
|
@ -329,21 +315,39 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
|
||||||
child->position.x = tpos.x;
|
child->position.x = tpos.x;
|
||||||
child->size.x = tsize.x;
|
child->size.x = tsize.x;
|
||||||
child->setHidden(this->hidden);
|
child->setHidden(this->hidden);
|
||||||
|
|
||||||
|
if (group->children.size() == 1) {
|
||||||
|
child->gap_pos_offset = gap_pos_offset;
|
||||||
|
child->gap_size_offset = gap_size_offset;
|
||||||
|
if (this->parent != nullptr) child->gap_size_offset.y += *group_inset;
|
||||||
|
child->size.y += gap_size_offset.y;
|
||||||
|
} else if (child == group->children.front()) {
|
||||||
|
child->gap_pos_offset = gap_pos_offset;
|
||||||
|
child->gap_size_offset = Vector2D(gap_size_offset.x, 0);
|
||||||
|
offset += gap_pos_offset.y;
|
||||||
|
} else if (child == group->children.back()) {
|
||||||
|
child->gap_pos_offset = Vector2D(gap_pos_offset.x, 0);
|
||||||
|
child->gap_size_offset = gap_size_offset;
|
||||||
|
child->size.y += gap_size_offset.y;
|
||||||
|
} else {
|
||||||
|
child->gap_pos_offset = Vector2D(gap_pos_offset.x, 0);
|
||||||
|
child->gap_size_offset = Vector2D(gap_size_offset.x, 0);
|
||||||
|
}
|
||||||
|
|
||||||
child->recalcSizePosRecursive(no_animation);
|
child->recalcSizePosRecursive(no_animation);
|
||||||
break;
|
break;
|
||||||
case Hy3GroupLayout::Tabbed:
|
case Hy3GroupLayout::Tabbed:
|
||||||
child->position.y = tpos.y + tab_height_offset;
|
child->position = tpos;
|
||||||
child->size.y = tsize.y - tab_height_offset;
|
child->size = tsize;
|
||||||
child->position.x = tpos.x;
|
|
||||||
child->size.x = tsize.x;
|
|
||||||
bool hidden = this->hidden || group->focused_child != child;
|
bool hidden = this->hidden || group->focused_child != child;
|
||||||
child->setHidden(hidden);
|
child->setHidden(hidden);
|
||||||
|
|
||||||
|
child->gap_pos_offset = Vector2D(gap_pos_offset.x, gap_pos_offset.y + tab_height_offset);
|
||||||
|
child->gap_size_offset = Vector2D(gap_size_offset.x, gap_size_offset.y + tab_height_offset);
|
||||||
|
|
||||||
child->recalcSizePosRecursive(no_animation);
|
child->recalcSizePosRecursive(no_animation);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
child->gap_pos_offset = gap_pos_offset;
|
|
||||||
child->gap_size_offset = gap_pos_offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->updateTabBar(no_animation);
|
this->updateTabBar(no_animation);
|
||||||
|
|
Loading…
Add table
Reference in a new issue