Skip to content

Commit

Permalink
share node size calculations between positioner and tabs
Browse files Browse the repository at this point in the history
Partially fixes blurry tabs.
  • Loading branch information
outfoxxed committed Sep 5, 2024
1 parent 9612917 commit 1456c82
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 35 deletions.
31 changes: 6 additions & 25 deletions src/Hy3Layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1514,10 +1514,7 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) {
return;
}

// clang-format off
static const auto gaps_in = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_in");
static const auto no_gaps_when_only = ConfigValue<Hyprlang::INT>("plugin:hy3:no_gaps_when_only");
// clang-format on

if (!valid(window) || !window->m_bIsMapped) {
hy3_log(
Expand All @@ -1544,14 +1541,15 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) {
&& root_node->data.as_group().children.front()->data.is_window();

if (!window->m_pWorkspace->m_bIsSpecialWorkspace
&& ((*no_gaps_when_only != 0 && (only_node || window->isFullscreen()))
|| window->isEffectiveInternalFSMode(FSMODE_FULLSCREEN)))
&& ((*no_gaps_when_only != 0 && (only_node || window->isFullscreen()))
|| window->isEffectiveInternalFSMode(FSMODE_FULLSCREEN)))
{
window->m_sWindowData.decorate = CWindowOverridableVar(
true,
PRIORITY_LAYOUT
); // a little curious but copying what dwindle does
window->m_sWindowData.noBorder = CWindowOverridableVar(*no_gaps_when_only != 2, PRIORITY_LAYOUT);
window->m_sWindowData.noBorder =
CWindowOverridableVar(*no_gaps_when_only != 2, PRIORITY_LAYOUT);
window->m_sWindowData.noRounding = CWindowOverridableVar(true, PRIORITY_LAYOUT);
window->m_sWindowData.noShadow = CWindowOverridableVar(true, PRIORITY_LAYOUT);

Expand All @@ -1564,25 +1562,8 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) {

g_pXWaylandManager->setWindowSize(window, window->m_vRealSize.goal());
} else {
auto calcPos = window->m_vPosition;
auto calcSize = window->m_vSize;

auto gaps_offset_topleft =
Vector2D((int) gaps_in->left, (int) gaps_in->top) + node->gap_topleft_offset;

auto gaps_offset_bottomright =
Vector2D((int) (gaps_in->left + gaps_in->right), (int) (gaps_in->top + gaps_in->bottom))
+ node->gap_bottomright_offset + node->gap_topleft_offset;

calcPos = calcPos + gaps_offset_topleft;
calcSize = calcSize - gaps_offset_bottomright;

const auto reserved_area = window->getFullWindowReservedArea();
calcPos = calcPos + reserved_area.topLeft;
calcSize = calcSize - (reserved_area.topLeft + reserved_area.bottomRight);

CBox wb = {calcPos, calcSize};
wb.round();
auto reserved = window->getFullWindowReservedArea();
auto wb = node->getStandardWindowArea({-reserved.topLeft, -reserved.bottomRight});

window->m_vRealPosition = wb.pos();
window->m_vRealSize = wb.size();
Expand Down
20 changes: 20 additions & 0 deletions src/Hy3Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,26 @@ void Hy3Node::setHidden(bool hidden) {
}
}

CBox Hy3Node::getStandardWindowArea(SBoxExtents extents) {
static const auto gaps_in = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_in");

SBoxExtents inner_gap_extents;
inner_gap_extents.topLeft = {(int) -gaps_in->left, (int) -gaps_in->top};
inner_gap_extents.bottomRight = {(int) -gaps_in->right, (int) -gaps_in->bottom};

SBoxExtents combined_outer_extents;
combined_outer_extents.topLeft = -this->gap_topleft_offset;
combined_outer_extents.bottomRight = -this->gap_bottomright_offset;

auto area = CBox(this->position, this->size);
area.addExtents(inner_gap_extents);
area.addExtents(combined_outer_extents);
area.addExtents(extents);

area.round();
return area;
}

Hy3Node* Hy3Node::findNodeForTabGroup(Hy3TabGroup& tab_group) {
if (this->data.is_group()) {
if (this->hidden) return nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/Hy3Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ struct Hy3Node {
std::string getTitle();
bool isUrgent();
void setHidden(bool);
CBox getStandardWindowArea(SBoxExtents extents = SBoxExtents());

Hy3Node* findNodeForTabGroup(Hy3TabGroup&);
void appendAllWindows(std::vector<PHLWINDOW>&);
Expand Down
13 changes: 3 additions & 10 deletions src/TabGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,19 +414,12 @@ Hy3TabGroup::Hy3TabGroup(Hy3Node& node) {
}

void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) {
static const auto gaps_in = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_in");
static const auto gaps_out = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_out");
static const auto bar_height = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:height");

auto& gaps = node.parent == nullptr ? gaps_out : gaps_in;
auto tpos = node.position + Vector2D((int) gaps->left, (int) gaps->top) + node.gap_topleft_offset;
auto windowBox = node.getStandardWindowArea();

// clang-format off
auto tsize = Vector2D(
node.size.x - node.gap_bottomright_offset.x - node.gap_topleft_offset.x - (gaps->left + gaps->right),
*bar_height
);
// clang-format on
auto tpos = windowBox.pos();
auto tsize = Vector2D(windowBox.size().x, *bar_height);

this->hidden = node.hidden;
if (this->pos.goal() != tpos) {
Expand Down

0 comments on commit 1456c82

Please sign in to comment.