Skip to content

Commit

Permalink
xdg_shell: improve xdg_positioner resize calculations
Browse files Browse the repository at this point in the history
ref #6240
  • Loading branch information
vaxerski committed Jun 7, 2024
1 parent 429cff3 commit d633714
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/protocols/XDGShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ CBox CXDGPositionerRules::getPosition(const CBox& constraint, const Vector2D& pa
bool success = predictedBox.inside(constraint);

if (success)
return predictedBox.translate(-parentCoord - constraint.pos());
return predictedBox;

if (state.constraintAdjustment & (XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X | XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y)) {
// attempt to flip
Expand All @@ -547,7 +547,7 @@ CBox CXDGPositionerRules::getPosition(const CBox& constraint, const Vector2D& pa
success = false;

if (success)
return test.translate(-parentCoord - constraint.pos());
return test;
}

// if flips fail, we will slide and remember.
Expand Down Expand Up @@ -584,7 +584,7 @@ CBox CXDGPositionerRules::getPosition(const CBox& constraint, const Vector2D& pa
success = test.copy().expand(-1).inside(constraint);

if (success)
return test.translate(-parentCoord - constraint.pos());
return test;
}

if (state.constraintAdjustment & (XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X | XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y)) {
Expand All @@ -602,18 +602,18 @@ CBox CXDGPositionerRules::getPosition(const CBox& constraint, const Vector2D& pa
test.x = constraint.x + EDGE_PADDING;
}
if (rightEdgeOut && resizeX)
test.w = -(constraint.w + constraint.x - test.w - test.x + EDGE_PADDING);
test.w = constraint.w - (test.x - constraint.w) - EDGE_PADDING;
if (topEdgeOut && resizeY) {
test.h = test.y + test.h - constraint.y - EDGE_PADDING;
test.y = constraint.y + EDGE_PADDING;
}
if (bottomEdgeOut && resizeY)
test.h = -(constraint.h + constraint.y - test.h - test.y + EDGE_PADDING);
test.h = constraint.h - (test.y - constraint.y) - EDGE_PADDING;

success = test.copy().expand(-1).inside(constraint);

if (success)
return test.translate(parentCoord - constraint.pos());
return test;
}

LOGM(WARN, "Compositor/client bug: xdg_positioner couldn't find a place");
Expand Down

0 comments on commit d633714

Please sign in to comment.