Rename popupPosition to popupRect
Summary: popupPosition implies that it is a QPoint, which is false. Test Plan: Compiles. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D27125icc-effect-master
parent
432787e036
commit
84f0d51f40
|
@ -1642,7 +1642,6 @@ QRect XdgShellClient::transientPlacement(const QRect &bounds) const
|
||||||
QSize size = frameGeometry().size();
|
QSize size = frameGeometry().size();
|
||||||
|
|
||||||
const QPoint parentClientPos = transientFor()->pos() + transientFor()->clientPos();
|
const QPoint parentClientPos = transientFor()->pos() + transientFor()->clientPos();
|
||||||
QRect popupPosition;
|
|
||||||
|
|
||||||
// returns if a target is within the supplied bounds, optional edges argument states which side to check
|
// returns if a target is within the supplied bounds, optional edges argument states which side to check
|
||||||
auto inBounds = [bounds](const QRect &target, Qt::Edges edges = Qt::LeftEdge | Qt::RightEdge | Qt::TopEdge | Qt::BottomEdge) -> bool {
|
auto inBounds = [bounds](const QRect &target, Qt::Edges edges = Qt::LeftEdge | Qt::RightEdge | Qt::TopEdge | Qt::BottomEdge) -> bool {
|
||||||
|
@ -1671,17 +1670,16 @@ QRect XdgShellClient::transientPlacement(const QRect &bounds) const
|
||||||
size = m_xdgShellPopup->initialSize();
|
size = m_xdgShellPopup->initialSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
//initial position
|
QRect popupRect(popupOffset(anchorRect, anchorEdge, gravity, size) + offset + parentClientPos, size);
|
||||||
popupPosition = QRect(popupOffset(anchorRect, anchorEdge, gravity, size) + offset + parentClientPos, size);
|
|
||||||
|
|
||||||
//if that fits, we don't need to do anything
|
//if that fits, we don't need to do anything
|
||||||
if (inBounds(popupPosition)) {
|
if (inBounds(popupRect)) {
|
||||||
return popupPosition;
|
return popupRect;
|
||||||
}
|
}
|
||||||
//otherwise apply constraint adjustment per axis in order XDG Shell Popup states
|
//otherwise apply constraint adjustment per axis in order XDG Shell Popup states
|
||||||
|
|
||||||
if (constraintAdjustments & PositionerConstraint::FlipX) {
|
if (constraintAdjustments & PositionerConstraint::FlipX) {
|
||||||
if (!inBounds(popupPosition, Qt::LeftEdge | Qt::RightEdge)) {
|
if (!inBounds(popupRect, Qt::LeftEdge | Qt::RightEdge)) {
|
||||||
//flip both edges (if either bit is set, XOR both)
|
//flip both edges (if either bit is set, XOR both)
|
||||||
auto flippedAnchorEdge = anchorEdge;
|
auto flippedAnchorEdge = anchorEdge;
|
||||||
if (flippedAnchorEdge & (Qt::LeftEdge | Qt::RightEdge)) {
|
if (flippedAnchorEdge & (Qt::LeftEdge | Qt::RightEdge)) {
|
||||||
|
@ -1691,24 +1689,24 @@ QRect XdgShellClient::transientPlacement(const QRect &bounds) const
|
||||||
if (flippedGravity & (Qt::LeftEdge | Qt::RightEdge)) {
|
if (flippedGravity & (Qt::LeftEdge | Qt::RightEdge)) {
|
||||||
flippedGravity ^= (Qt::LeftEdge | Qt::RightEdge);
|
flippedGravity ^= (Qt::LeftEdge | Qt::RightEdge);
|
||||||
}
|
}
|
||||||
auto flippedPopupPosition = QRect(popupOffset(anchorRect, flippedAnchorEdge, flippedGravity, size) + offset + parentClientPos, size);
|
auto flippedPopupRect = QRect(popupOffset(anchorRect, flippedAnchorEdge, flippedGravity, size) + offset + parentClientPos, size);
|
||||||
|
|
||||||
//if it still doesn't fit we should continue with the unflipped version
|
//if it still doesn't fit we should continue with the unflipped version
|
||||||
if (inBounds(flippedPopupPosition, Qt::LeftEdge | Qt::RightEdge)) {
|
if (inBounds(flippedPopupRect, Qt::LeftEdge | Qt::RightEdge)) {
|
||||||
popupPosition.moveLeft(flippedPopupPosition.x());
|
popupRect.moveLeft(flippedPopupRect.left());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (constraintAdjustments & PositionerConstraint::SlideX) {
|
if (constraintAdjustments & PositionerConstraint::SlideX) {
|
||||||
if (!inBounds(popupPosition, Qt::LeftEdge)) {
|
if (!inBounds(popupRect, Qt::LeftEdge)) {
|
||||||
popupPosition.moveLeft(bounds.x());
|
popupRect.moveLeft(bounds.left());
|
||||||
}
|
}
|
||||||
if (!inBounds(popupPosition, Qt::RightEdge)) {
|
if (!inBounds(popupRect, Qt::RightEdge)) {
|
||||||
popupPosition.moveRight(bounds.right());
|
popupRect.moveRight(bounds.right());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (constraintAdjustments & PositionerConstraint::ResizeX) {
|
if (constraintAdjustments & PositionerConstraint::ResizeX) {
|
||||||
QRect unconstrainedRect = popupPosition;
|
QRect unconstrainedRect = popupRect;
|
||||||
|
|
||||||
if (!inBounds(unconstrainedRect, Qt::LeftEdge)) {
|
if (!inBounds(unconstrainedRect, Qt::LeftEdge)) {
|
||||||
unconstrainedRect.setLeft(bounds.left());
|
unconstrainedRect.setLeft(bounds.left());
|
||||||
|
@ -1718,12 +1716,12 @@ QRect XdgShellClient::transientPlacement(const QRect &bounds) const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unconstrainedRect.isValid()) {
|
if (unconstrainedRect.isValid()) {
|
||||||
popupPosition = unconstrainedRect;
|
popupRect = unconstrainedRect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constraintAdjustments & PositionerConstraint::FlipY) {
|
if (constraintAdjustments & PositionerConstraint::FlipY) {
|
||||||
if (!inBounds(popupPosition, Qt::TopEdge | Qt::BottomEdge)) {
|
if (!inBounds(popupRect, Qt::TopEdge | Qt::BottomEdge)) {
|
||||||
//flip both edges (if either bit is set, XOR both)
|
//flip both edges (if either bit is set, XOR both)
|
||||||
auto flippedAnchorEdge = anchorEdge;
|
auto flippedAnchorEdge = anchorEdge;
|
||||||
if (flippedAnchorEdge & (Qt::TopEdge | Qt::BottomEdge)) {
|
if (flippedAnchorEdge & (Qt::TopEdge | Qt::BottomEdge)) {
|
||||||
|
@ -1733,24 +1731,24 @@ QRect XdgShellClient::transientPlacement(const QRect &bounds) const
|
||||||
if (flippedGravity & (Qt::TopEdge | Qt::BottomEdge)) {
|
if (flippedGravity & (Qt::TopEdge | Qt::BottomEdge)) {
|
||||||
flippedGravity ^= (Qt::TopEdge | Qt::BottomEdge);
|
flippedGravity ^= (Qt::TopEdge | Qt::BottomEdge);
|
||||||
}
|
}
|
||||||
auto flippedPopupPosition = QRect(popupOffset(anchorRect, flippedAnchorEdge, flippedGravity, size) + offset + parentClientPos, size);
|
auto flippedPopupRect = QRect(popupOffset(anchorRect, flippedAnchorEdge, flippedGravity, size) + offset + parentClientPos, size);
|
||||||
|
|
||||||
//if it still doesn't fit we should continue with the unflipped version
|
//if it still doesn't fit we should continue with the unflipped version
|
||||||
if (inBounds(flippedPopupPosition, Qt::TopEdge | Qt::BottomEdge)) {
|
if (inBounds(flippedPopupRect, Qt::TopEdge | Qt::BottomEdge)) {
|
||||||
popupPosition.moveTop(flippedPopupPosition.y());
|
popupRect.moveTop(flippedPopupRect.top());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (constraintAdjustments & PositionerConstraint::SlideY) {
|
if (constraintAdjustments & PositionerConstraint::SlideY) {
|
||||||
if (!inBounds(popupPosition, Qt::TopEdge)) {
|
if (!inBounds(popupRect, Qt::TopEdge)) {
|
||||||
popupPosition.moveTop(bounds.y());
|
popupRect.moveTop(bounds.top());
|
||||||
}
|
}
|
||||||
if (!inBounds(popupPosition, Qt::BottomEdge)) {
|
if (!inBounds(popupRect, Qt::BottomEdge)) {
|
||||||
popupPosition.moveBottom(bounds.bottom());
|
popupRect.moveBottom(bounds.bottom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (constraintAdjustments & PositionerConstraint::ResizeY) {
|
if (constraintAdjustments & PositionerConstraint::ResizeY) {
|
||||||
QRect unconstrainedRect = popupPosition;
|
QRect unconstrainedRect = popupRect;
|
||||||
|
|
||||||
if (!inBounds(unconstrainedRect, Qt::TopEdge)) {
|
if (!inBounds(unconstrainedRect, Qt::TopEdge)) {
|
||||||
unconstrainedRect.setTop(bounds.top());
|
unconstrainedRect.setTop(bounds.top());
|
||||||
|
@ -1760,11 +1758,11 @@ QRect XdgShellClient::transientPlacement(const QRect &bounds) const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unconstrainedRect.isValid()) {
|
if (unconstrainedRect.isValid()) {
|
||||||
popupPosition = unconstrainedRect;
|
popupRect = unconstrainedRect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return popupPosition;
|
return popupRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint XdgShellClient::popupOffset(const QRect &anchorRect, const Qt::Edges anchorEdge, const Qt::Edges gravity, const QSize popupSize) const
|
QPoint XdgShellClient::popupOffset(const QRect &anchorRect, const Qt::Edges anchorEdge, const Qt::Edges gravity, const QSize popupSize) const
|
||||||
|
|
Loading…
Reference in New Issue