Move move/resize related mouse command handling to AbstractClient
Code is refactored in a sufficient way so that we can handle the move/resize mouse commands also from AbstractClient::performMouseCommand.
This commit is contained in:
parent
f5848d9405
commit
717a48a2a1
2 changed files with 52 additions and 52 deletions
|
@ -896,6 +896,58 @@ bool AbstractClient::performMouseCommand(Options::MouseCommand cmd, const QPoint
|
|||
case Options::MouseClose:
|
||||
closeWindow();
|
||||
break;
|
||||
case Options::MouseActivateRaiseAndMove:
|
||||
case Options::MouseActivateRaiseAndUnrestrictedMove:
|
||||
workspace()->raiseClient(this);
|
||||
workspace()->requestFocus(this);
|
||||
screens()->setCurrent(globalPos);
|
||||
// fallthrough
|
||||
case Options::MouseMove:
|
||||
case Options::MouseUnrestrictedMove: {
|
||||
if (!isMovableAcrossScreens())
|
||||
break;
|
||||
if (isMoveResize())
|
||||
finishMoveResize(false);
|
||||
setMoveResizePointerMode(PositionCenter);
|
||||
setMoveResizePointerButtonDown(true);
|
||||
setMoveOffset(QPoint(globalPos.x() - x(), globalPos.y() - y())); // map from global
|
||||
setInvertedMoveOffset(rect().bottomRight() - moveOffset());
|
||||
setUnrestrictedMoveResize((cmd == Options::MouseActivateRaiseAndUnrestrictedMove
|
||||
|| cmd == Options::MouseUnrestrictedMove));
|
||||
if (!startMoveResize())
|
||||
setMoveResizePointerButtonDown(false);
|
||||
updateCursor();
|
||||
break;
|
||||
}
|
||||
case Options::MouseResize:
|
||||
case Options::MouseUnrestrictedResize: {
|
||||
if (!isResizable() || isShade())
|
||||
break;
|
||||
if (isMoveResize())
|
||||
finishMoveResize(false);
|
||||
setMoveResizePointerButtonDown(true);
|
||||
const QPoint moveOffset = QPoint(globalPos.x() - x(), globalPos.y() - y()); // map from global
|
||||
setMoveOffset(moveOffset);
|
||||
int x = moveOffset.x(), y = moveOffset.y();
|
||||
bool left = x < width() / 3;
|
||||
bool right = x >= 2 * width() / 3;
|
||||
bool top = y < height() / 3;
|
||||
bool bot = y >= 2 * height() / 3;
|
||||
Position mode;
|
||||
if (top)
|
||||
mode = left ? PositionTopLeft : (right ? PositionTopRight : PositionTop);
|
||||
else if (bot)
|
||||
mode = left ? PositionBottomLeft : (right ? PositionBottomRight : PositionBottom);
|
||||
else
|
||||
mode = (x < width() / 2) ? PositionLeft : PositionRight;
|
||||
setMoveResizePointerMode(mode);
|
||||
setInvertedMoveOffset(rect().bottomRight() - moveOffset);
|
||||
setUnrestrictedMoveResize((cmd == Options::MouseUnrestrictedResize));
|
||||
if (!startMoveResize())
|
||||
setMoveResizePointerButtonDown(false);
|
||||
updateCursor();
|
||||
break;
|
||||
}
|
||||
case Options::MouseDragTab:
|
||||
case Options::MouseNothing:
|
||||
default:
|
||||
|
|
|
@ -1208,58 +1208,6 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl
|
|||
setShade(ShadeNone);
|
||||
cancelShadeHoverTimer();
|
||||
break;
|
||||
case Options::MouseActivateRaiseAndMove:
|
||||
case Options::MouseActivateRaiseAndUnrestrictedMove:
|
||||
workspace()->raiseClient(this);
|
||||
workspace()->requestFocus(this);
|
||||
screens()->setCurrent(globalPos);
|
||||
// fallthrough
|
||||
case Options::MouseMove:
|
||||
case Options::MouseUnrestrictedMove: {
|
||||
if (!isMovableAcrossScreens())
|
||||
break;
|
||||
if (isMoveResize())
|
||||
finishMoveResize(false);
|
||||
setMoveResizePointerMode(PositionCenter);
|
||||
setMoveResizePointerButtonDown(true);
|
||||
setMoveOffset(QPoint(globalPos.x() - x(), globalPos.y() - y())); // map from global
|
||||
setInvertedMoveOffset(rect().bottomRight() - moveOffset());
|
||||
setUnrestrictedMoveResize((command == Options::MouseActivateRaiseAndUnrestrictedMove
|
||||
|| command == Options::MouseUnrestrictedMove));
|
||||
if (!startMoveResize())
|
||||
setMoveResizePointerButtonDown(false);
|
||||
updateCursor();
|
||||
break;
|
||||
}
|
||||
case Options::MouseResize:
|
||||
case Options::MouseUnrestrictedResize: {
|
||||
if (!isResizable() || isShade())
|
||||
break;
|
||||
if (isMoveResize())
|
||||
finishMoveResize(false);
|
||||
setMoveResizePointerButtonDown(true);
|
||||
const QPoint moveOffset = QPoint(globalPos.x() - x(), globalPos.y() - y()); // map from global
|
||||
setMoveOffset(moveOffset);
|
||||
int x = moveOffset.x(), y = moveOffset.y();
|
||||
bool left = x < width() / 3;
|
||||
bool right = x >= 2 * width() / 3;
|
||||
bool top = y < height() / 3;
|
||||
bool bot = y >= 2 * height() / 3;
|
||||
Position mode;
|
||||
if (top)
|
||||
mode = left ? PositionTopLeft : (right ? PositionTopRight : PositionTop);
|
||||
else if (bot)
|
||||
mode = left ? PositionBottomLeft : (right ? PositionBottomRight : PositionBottom);
|
||||
else
|
||||
mode = (x < width() / 2) ? PositionLeft : PositionRight;
|
||||
setMoveResizePointerMode(mode);
|
||||
setInvertedMoveOffset(rect().bottomRight() - moveOffset);
|
||||
setUnrestrictedMoveResize((command == Options::MouseUnrestrictedResize));
|
||||
if (!startMoveResize())
|
||||
setMoveResizePointerButtonDown(false);
|
||||
updateCursor();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return AbstractClient::performMouseCommand(command, globalPos);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue