xdg_shell: improve xdg_positioner resize calculations

ref #6240
This commit is contained in:
Vaxry 2024-06-07 18:42:31 +02:00
parent 429cff340d
commit d6337146bb

View file

@ -528,7 +528,7 @@ CBox CXDGPositionerRules::getPosition(const CBox& constraint, const Vector2D& pa
bool success = predictedBox.inside(constraint); bool success = predictedBox.inside(constraint);
if (success) 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)) { if (state.constraintAdjustment & (XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X | XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y)) {
// attempt to flip // attempt to flip
@ -547,7 +547,7 @@ CBox CXDGPositionerRules::getPosition(const CBox& constraint, const Vector2D& pa
success = false; success = false;
if (success) if (success)
return test.translate(-parentCoord - constraint.pos()); return test;
} }
// if flips fail, we will slide and remember. // if flips fail, we will slide and remember.
@ -584,7 +584,7 @@ CBox CXDGPositionerRules::getPosition(const CBox& constraint, const Vector2D& pa
success = test.copy().expand(-1).inside(constraint); success = test.copy().expand(-1).inside(constraint);
if (success) 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)) { if (state.constraintAdjustment & (XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X | XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y)) {
@ -602,18 +602,18 @@ CBox CXDGPositionerRules::getPosition(const CBox& constraint, const Vector2D& pa
test.x = constraint.x + EDGE_PADDING; test.x = constraint.x + EDGE_PADDING;
} }
if (rightEdgeOut && resizeX) 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) { if (topEdgeOut && resizeY) {
test.h = test.y + test.h - constraint.y - EDGE_PADDING; test.h = test.y + test.h - constraint.y - EDGE_PADDING;
test.y = constraint.y + EDGE_PADDING; test.y = constraint.y + EDGE_PADDING;
} }
if (bottomEdgeOut && resizeY) 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); success = test.copy().expand(-1).inside(constraint);
if (success) if (success)
return test.translate(parentCoord - constraint.pos()); return test;
} }
LOGM(WARN, "Compositor/client bug: xdg_positioner couldn't find a place"); LOGM(WARN, "Compositor/client bug: xdg_positioner couldn't find a place");