Round X window gravity adjustment
Qt applications use Static window gravity by default. This means that if a window decoration is created, the client window should remain at the same position in the global coordinate space. To do that, X11Window needs to move the frame geometry by (-borderLeft(), -borderTop()). On the other hand, after making X11Window::framePosToClientPos() round the window borders, the client window can end up being moved more than expected when applying the gravity adjustment. This change makes X11Window also round the gravity adjustment so the math is consistent there and in the framePosToClientPos() function. BUG: 489016
This commit is contained in:
parent
282137c41d
commit
84e3ff88c3
1 changed files with 16 additions and 16 deletions
|
@ -3948,48 +3948,48 @@ QPointF X11Window::gravityAdjustment(xcb_gravity_t gravity) const
|
||||||
switch (gravity) {
|
switch (gravity) {
|
||||||
case XCB_GRAVITY_NORTH_WEST: // move down right
|
case XCB_GRAVITY_NORTH_WEST: // move down right
|
||||||
default:
|
default:
|
||||||
dx = borderLeft();
|
dx = Xcb::nativeRound(borderLeft());
|
||||||
dy = borderTop();
|
dy = Xcb::nativeRound(borderTop());
|
||||||
break;
|
break;
|
||||||
case XCB_GRAVITY_NORTH: // move right
|
case XCB_GRAVITY_NORTH: // move right
|
||||||
dx = 0;
|
dx = 0;
|
||||||
dy = borderTop();
|
dy = Xcb::nativeRound(borderTop());
|
||||||
break;
|
break;
|
||||||
case XCB_GRAVITY_NORTH_EAST: // move down left
|
case XCB_GRAVITY_NORTH_EAST: // move down left
|
||||||
dx = -borderRight();
|
dx = -Xcb::nativeRound(borderRight());
|
||||||
dy = borderTop();
|
dy = Xcb::nativeRound(borderTop());
|
||||||
break;
|
break;
|
||||||
case XCB_GRAVITY_WEST: // move right
|
case XCB_GRAVITY_WEST: // move right
|
||||||
dx = borderLeft();
|
dx = borderLeft();
|
||||||
dy = 0;
|
dy = 0;
|
||||||
break;
|
break;
|
||||||
case XCB_GRAVITY_CENTER:
|
case XCB_GRAVITY_CENTER:
|
||||||
dx = (borderLeft() - borderRight()) / 2;
|
dx = Xcb::fromXNative((int(Xcb::toXNative(borderLeft())) - int(Xcb::toXNative(borderRight()))) / 2);
|
||||||
dy = (borderTop() - borderBottom()) / 2;
|
dy = Xcb::fromXNative((int(Xcb::toXNative(borderTop())) - int(Xcb::toXNative(borderBottom()))) / 2);
|
||||||
break;
|
break;
|
||||||
case XCB_GRAVITY_STATIC: // don't move
|
case XCB_GRAVITY_STATIC: // don't move
|
||||||
dx = 0;
|
dx = 0;
|
||||||
dy = 0;
|
dy = 0;
|
||||||
break;
|
break;
|
||||||
case XCB_GRAVITY_EAST: // move left
|
case XCB_GRAVITY_EAST: // move left
|
||||||
dx = -borderRight();
|
dx = -Xcb::nativeRound(borderRight());
|
||||||
dy = 0;
|
dy = 0;
|
||||||
break;
|
break;
|
||||||
case XCB_GRAVITY_SOUTH_WEST: // move up right
|
case XCB_GRAVITY_SOUTH_WEST: // move up right
|
||||||
dx = borderLeft();
|
dx = Xcb::nativeRound(borderLeft());
|
||||||
dy = -borderBottom();
|
dy = -Xcb::nativeRound(borderBottom());
|
||||||
break;
|
break;
|
||||||
case XCB_GRAVITY_SOUTH: // move up
|
case XCB_GRAVITY_SOUTH: // move up
|
||||||
dx = 0;
|
dx = 0;
|
||||||
dy = -borderBottom();
|
dy = -Xcb::nativeRound(borderBottom());
|
||||||
break;
|
break;
|
||||||
case XCB_GRAVITY_SOUTH_EAST: // move up left
|
case XCB_GRAVITY_SOUTH_EAST: // move up left
|
||||||
dx = -borderRight();
|
dx = -Xcb::nativeRound(borderRight());
|
||||||
dy = -borderBottom();
|
dy = -Xcb::nativeRound(borderBottom());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QPoint(dx, dy);
|
return QPointF(dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPointF X11Window::calculateGravitation(bool invert) const
|
const QPointF X11Window::calculateGravitation(bool invert) const
|
||||||
|
@ -3997,8 +3997,8 @@ const QPointF X11Window::calculateGravitation(bool invert) const
|
||||||
const QPointF adjustment = gravityAdjustment(m_geometryHints.windowGravity());
|
const QPointF adjustment = gravityAdjustment(m_geometryHints.windowGravity());
|
||||||
|
|
||||||
// translate from client movement to frame movement
|
// translate from client movement to frame movement
|
||||||
const qreal dx = adjustment.x() - borderLeft();
|
const qreal dx = adjustment.x() - Xcb::nativeRound(borderLeft());
|
||||||
const qreal dy = adjustment.y() - borderTop();
|
const qreal dy = adjustment.y() - Xcb::nativeRound(borderTop());
|
||||||
|
|
||||||
if (!invert) {
|
if (!invert) {
|
||||||
return QPointF(x() + dx, y() + dy);
|
return QPointF(x() + dx, y() + dy);
|
||||||
|
|
Loading…
Reference in a new issue