Move code to initiate interactive move by dragging the decoration outside Window::handleInteractiveMoveResize()
The main motivation behind this change is to make the code in Window::handleInteractiveMoveResize() more reasonable. Almost all of the code in it will be called after startInteractiveMoveResize(), except when one drags the decoration to initiate an interactive move operation. This change moves that code to the places where it makes more sense to ensure that handleInteractiveMoveResize() has no any hidden pitfalls.
This commit is contained in:
parent
7db47ac2fd
commit
2663756ebf
3 changed files with 37 additions and 33 deletions
|
@ -1184,9 +1184,23 @@ bool X11Window::motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x
|
|||
y = this->y();
|
||||
}
|
||||
|
||||
handleInteractiveMoveResize(QPoint(x, y), QPoint(x_root, y_root));
|
||||
if (isInteractiveMove()) {
|
||||
workspace()->screenEdges()->check(QPoint(x_root, y_root), QDateTime::fromMSecsSinceEpoch(xTime(), Qt::UTC));
|
||||
if (!isInteractiveMoveResize()) {
|
||||
const QPointF offset(interactiveMoveOffset().x() * width(), interactiveMoveOffset().y() * height());
|
||||
const QPointF delta(QPointF(x, y) - offset);
|
||||
if (delta.manhattanLength() >= QApplication::startDragDistance()) {
|
||||
if (startInteractiveMoveResize()) {
|
||||
updateInteractiveMoveResize(QPointF(x_root, y_root));
|
||||
} else {
|
||||
setInteractiveMoveResizePointerButtonDown(false);
|
||||
}
|
||||
updateCursor();
|
||||
}
|
||||
} else {
|
||||
updateInteractiveMoveResize(QPointF(x_root, y_root));
|
||||
|
||||
if (isInteractiveMove()) {
|
||||
workspace()->screenEdges()->check(QPoint(x_root, y_root), QDateTime::fromMSecsSinceEpoch(xTime(), Qt::UTC));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1190,6 +1190,10 @@ bool Window::startInteractiveMoveResize()
|
|||
if (isRequestedFullScreen() && (workspace()->outputs().count() < 2 || !isMovableAcrossScreens())) {
|
||||
return false;
|
||||
}
|
||||
if ((interactiveMoveResizeGravity() == Gravity::None && !isMovableAcrossScreens())
|
||||
|| (interactiveMoveResizeGravity() != Gravity::None && (isShade() || !isResizable()))) {
|
||||
return false;
|
||||
}
|
||||
if (!doStartInteractiveMoveResize()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1371,37 +1375,12 @@ void Window::stopDelayedInteractiveMoveResize()
|
|||
m_interactiveMoveResize.delayedTimer = nullptr;
|
||||
}
|
||||
|
||||
void Window::updateInteractiveMoveResize(const QPointF ¤tGlobalCursor)
|
||||
{
|
||||
handleInteractiveMoveResize(pos(), currentGlobalCursor);
|
||||
}
|
||||
|
||||
void Window::handleInteractiveMoveResize(const QPointF &local, const QPointF &global)
|
||||
void Window::updateInteractiveMoveResize(const QPointF &global)
|
||||
{
|
||||
setInteractiveMoveResizeAnchor(global);
|
||||
|
||||
const Gravity gravity = interactiveMoveResizeGravity();
|
||||
if ((gravity == Gravity::None && !isMovableAcrossScreens())
|
||||
|| (gravity != Gravity::None && (isShade() || !isResizable()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isInteractiveMoveResize()) {
|
||||
const QPointF offset(interactiveMoveOffset().x() * width(), interactiveMoveOffset().y() * height());
|
||||
const QPointF p(local - offset);
|
||||
if (p.manhattanLength() >= QApplication::startDragDistance()) {
|
||||
if (!startInteractiveMoveResize()) {
|
||||
setInteractiveMoveResizePointerButtonDown(false);
|
||||
updateCursor();
|
||||
return;
|
||||
}
|
||||
updateCursor();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// ShadeHover or ShadeActive, ShadeNormal was already avoided above
|
||||
const Gravity gravity = interactiveMoveResizeGravity();
|
||||
if (gravity != Gravity::None && shadeMode() != ShadeNone) {
|
||||
setShade(ShadeNone);
|
||||
}
|
||||
|
@ -2730,9 +2709,21 @@ void Window::layoutDecorationRects(QRectF &left, QRectF &top, QRectF &right, QRe
|
|||
void Window::processDecorationMove(const QPointF &localPos, const QPointF &globalPos)
|
||||
{
|
||||
if (isInteractiveMoveResizePointerButtonDown()) {
|
||||
handleInteractiveMoveResize(localPos, globalPos);
|
||||
if (!isInteractiveMoveResize()) {
|
||||
const QPointF offset(interactiveMoveOffset().x() * width(), interactiveMoveOffset().y() * height());
|
||||
const QPointF delta(localPos - offset);
|
||||
if (delta.manhattanLength() >= QApplication::startDragDistance()) {
|
||||
if (startInteractiveMoveResize()) {
|
||||
updateInteractiveMoveResize(globalPos);
|
||||
} else {
|
||||
setInteractiveMoveResizePointerButtonDown(false);
|
||||
}
|
||||
updateCursor();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: handle modifiers
|
||||
Gravity newGravity = mouseGravity();
|
||||
if (newGravity != interactiveMoveResizeGravity()) {
|
||||
|
|
|
@ -1128,7 +1128,7 @@ public:
|
|||
}
|
||||
uint32_t interactiveMoveResizeCount() const;
|
||||
|
||||
void updateInteractiveMoveResize(const QPointF ¤tGlobalCursor);
|
||||
void updateInteractiveMoveResize(const QPointF &global);
|
||||
/**
|
||||
* Ends move resize when all pointer buttons are up again.
|
||||
*/
|
||||
|
@ -1682,7 +1682,6 @@ protected:
|
|||
* Default implementation does nothing.
|
||||
*/
|
||||
virtual void doInteractiveResizeSync(const QRectF &rect);
|
||||
void handleInteractiveMoveResize(const QPointF &local, const QPointF &global);
|
||||
QRectF titleBarRect(const QRectF &rect, bool &transposed, int &requiredPixels) const;
|
||||
QRectF nextInteractiveMoveGeometry(const QPointF &global) const;
|
||||
QRectF nextInteractiveResizeGeometry(const QPointF &global) const;
|
||||
|
|
Loading…
Reference in a new issue