Window: Extract title bar rect code to the separate function
This will allow code reuse.
This commit is contained in:
parent
56d3c797cc
commit
10e41fc948
2 changed files with 29 additions and 27 deletions
|
@ -1420,6 +1420,34 @@ void Window::handleInteractiveMoveResize(const QPointF &local, const QPointF &gl
|
|||
}
|
||||
}
|
||||
|
||||
QRectF Window::titleBarRect(const QRectF &rect, bool &transposed, int &requiredPixels) const
|
||||
{
|
||||
QRectF titleRect = rect;
|
||||
titleRect.moveTopLeft(QPointF(0, 0));
|
||||
switch (titlebarPosition()) {
|
||||
default:
|
||||
case Qt::TopEdge:
|
||||
titleRect.setHeight(borderTop());
|
||||
break;
|
||||
case Qt::LeftEdge:
|
||||
titleRect.setWidth(borderLeft());
|
||||
transposed = true;
|
||||
break;
|
||||
case Qt::BottomEdge:
|
||||
titleRect.setTop(titleRect.bottom() - borderBottom());
|
||||
break;
|
||||
case Qt::RightEdge:
|
||||
titleRect.setLeft(titleRect.right() - borderRight());
|
||||
transposed = true;
|
||||
break;
|
||||
}
|
||||
// When doing a restricted move we must always keep 100px of the titlebar
|
||||
// visible to allow the user to be able to move it again.
|
||||
requiredPixels = std::min(100 * (transposed ? titleRect.width() : titleRect.height()),
|
||||
rect.width() * rect.height());
|
||||
return titleRect;
|
||||
}
|
||||
|
||||
void Window::handleInteractiveMoveResize(qreal x, qreal y, qreal x_root, qreal y_root)
|
||||
{
|
||||
if (isWaitingForInteractiveMoveResizeSync()) {
|
||||
|
@ -1461,33 +1489,6 @@ void Window::handleInteractiveMoveResize(qreal x, qreal y, qreal x_root, qreal y
|
|||
|
||||
// TODO move whole group when moving its leader or when the leader is not mapped?
|
||||
|
||||
auto titleBarRect = [this](const QRectF &rect, bool &transposed, int &requiredPixels) -> QRectF {
|
||||
QRectF titleRect = rect;
|
||||
titleRect.moveTopLeft(QPointF(0, 0));
|
||||
switch (titlebarPosition()) {
|
||||
default:
|
||||
case Qt::TopEdge:
|
||||
titleRect.setHeight(borderTop());
|
||||
break;
|
||||
case Qt::LeftEdge:
|
||||
titleRect.setWidth(borderLeft());
|
||||
transposed = true;
|
||||
break;
|
||||
case Qt::BottomEdge:
|
||||
titleRect.setTop(titleRect.bottom() - borderBottom());
|
||||
break;
|
||||
case Qt::RightEdge:
|
||||
titleRect.setLeft(titleRect.right() - borderRight());
|
||||
transposed = true;
|
||||
break;
|
||||
}
|
||||
// When doing a restricted move we must always keep 100px of the titlebar
|
||||
// visible to allow the user to be able to move it again.
|
||||
requiredPixels = std::min(100 * (transposed ? titleRect.width() : titleRect.height()),
|
||||
rect.width() * rect.height());
|
||||
return titleRect;
|
||||
};
|
||||
|
||||
if (isInteractiveResize()) {
|
||||
if (m_tile && m_tile->supportsResizeGravity(gravity)) {
|
||||
m_tile->resizeFromGravity(gravity, x_root, y_root);
|
||||
|
|
|
@ -1680,6 +1680,7 @@ protected:
|
|||
virtual void doInteractiveResizeSync(const QRectF &rect);
|
||||
void handleInteractiveMoveResize(qreal x, qreal y, qreal x_root, qreal y_root);
|
||||
void handleInteractiveMoveResize(const QPointF &local, const QPointF &global);
|
||||
QRectF titleBarRect(const QRectF &rect, bool &transposed, int &requiredPixels) const;
|
||||
void dontInteractiveMoveResize();
|
||||
|
||||
virtual QSizeF resizeIncrements() const;
|
||||
|
|
Loading…
Reference in a new issue