Introduce Window::interactiveMoveResizeAnchor
This provides the grab point that controls the interactive move resize operation. It can be used outside Window::handleInteractiveMoveResize() to position XdgToplevelWindow when a configure event is acked.
This commit is contained in:
parent
5d313fdd7b
commit
3e4c2b3ec8
4 changed files with 16 additions and 0 deletions
|
@ -1323,6 +1323,7 @@ void X11Window::NETMoveResize(qreal x_root, qreal y_root, NET::Direction directi
|
|||
finishInteractiveMoveResize(false);
|
||||
}
|
||||
setInteractiveMoveResizePointerButtonDown(true);
|
||||
setInteractiveMoveResizeAnchor(QPointF(x_root, y_root));
|
||||
setInteractiveMoveOffset(QPointF(qreal(x_root - x()) / width(), qreal(y_root - y()) / height())); // map from global
|
||||
setUnrestrictedInteractiveMoveResize(false);
|
||||
setInteractiveMoveResizeGravity(convert[direction]);
|
||||
|
|
|
@ -1378,6 +1378,8 @@ void Window::updateInteractiveMoveResize(const QPointF ¤tGlobalCursor)
|
|||
|
||||
void Window::handleInteractiveMoveResize(const QPointF &local, const QPointF &global)
|
||||
{
|
||||
setInteractiveMoveResizeAnchor(global);
|
||||
|
||||
const Gravity gravity = interactiveMoveResizeGravity();
|
||||
if ((gravity == Gravity::None && !isMovableAcrossScreens())
|
||||
|| (gravity != Gravity::None && (isShade() || !isResizable()))) {
|
||||
|
@ -2171,6 +2173,7 @@ bool Window::performMouseCommand(Options::MouseCommand cmd, const QPointF &globa
|
|||
}
|
||||
setInteractiveMoveResizeGravity(Gravity::None);
|
||||
setInteractiveMoveResizePointerButtonDown(true);
|
||||
setInteractiveMoveResizeAnchor(globalPos);
|
||||
setInteractiveMoveOffset(QPointF(qreal(globalPos.x() - x()) / width(), qreal(globalPos.y() - y()) / height())); // map from global
|
||||
setUnrestrictedInteractiveMoveResize((cmd == Options::MouseActivateRaiseAndUnrestrictedMove
|
||||
|| cmd == Options::MouseUnrestrictedMove));
|
||||
|
@ -2189,6 +2192,7 @@ bool Window::performMouseCommand(Options::MouseCommand cmd, const QPointF &globa
|
|||
finishInteractiveMoveResize(false);
|
||||
}
|
||||
setInteractiveMoveResizePointerButtonDown(true);
|
||||
setInteractiveMoveResizeAnchor(globalPos);
|
||||
const QPointF moveOffset = QPointF(globalPos.x() - x(), globalPos.y() - y()); // map from global
|
||||
setInteractiveMoveOffset(QPointF(moveOffset.x() / width(), moveOffset.y() / height()));
|
||||
int x = moveOffset.x(), y = moveOffset.y();
|
||||
|
@ -2796,6 +2800,7 @@ bool Window::processDecorationButtonPress(QMouseEvent *event, bool ignoreMenu)
|
|||
{
|
||||
setInteractiveMoveResizeGravity(mouseGravity());
|
||||
setInteractiveMoveResizePointerButtonDown(true);
|
||||
setInteractiveMoveResizeAnchor(event->globalPosition());
|
||||
setInteractiveMoveOffset(QPointF(qreal(event->pos().x()) / width(), qreal(event->pos().y()) / height()));
|
||||
setUnrestrictedInteractiveMoveResize(false);
|
||||
startDelayedInteractiveMoveResize();
|
||||
|
|
|
@ -1115,6 +1115,10 @@ public:
|
|||
{
|
||||
return isInteractiveMoveResize() && interactiveMoveResizeGravity() != Gravity::None;
|
||||
}
|
||||
QPointF interactiveMoveResizeAnchor() const
|
||||
{
|
||||
return m_interactiveMoveResize.anchor;
|
||||
}
|
||||
/**
|
||||
* Cursor shape for move/resize mode.
|
||||
*/
|
||||
|
@ -1576,6 +1580,10 @@ protected:
|
|||
{
|
||||
m_interactiveMoveResize.enabled = enabled;
|
||||
}
|
||||
void setInteractiveMoveResizeAnchor(const QPointF &anchor)
|
||||
{
|
||||
m_interactiveMoveResize.anchor = anchor;
|
||||
}
|
||||
/**
|
||||
* @returns whether the move resize mode is unrestricted.
|
||||
*/
|
||||
|
@ -1800,6 +1808,7 @@ protected:
|
|||
{
|
||||
bool enabled = false;
|
||||
bool unrestricted = false;
|
||||
QPointF anchor;
|
||||
QPointF offset;
|
||||
QRectF initialGeometry;
|
||||
QRectF initialGeometryRestore;
|
||||
|
|
|
@ -959,6 +959,7 @@ void XdgToplevelWindow::handleResizeRequested(SeatInterface *seat, XdgToplevelIn
|
|||
} else {
|
||||
cursorPos = input()->tablet()->position();
|
||||
}
|
||||
setInteractiveMoveResizeAnchor(cursorPos);
|
||||
setInteractiveMoveOffset(QPointF((cursorPos.x() - x()) / width(), (cursorPos.y() - y()) / height())); // map from global
|
||||
setUnrestrictedInteractiveMoveResize(false);
|
||||
Gravity gravity;
|
||||
|
|
Loading…
Reference in a new issue