Make AbstractClient::titlebarPosition() return Qt::Edge

Conceptually, it's an edge, the titlebar can't be in a window corner.
master
Vlad Zahorodnii 3 years ago
parent 63a2a88e6c
commit 5420e11bd4

@ -181,7 +181,7 @@ void DecorationInputTest::testAxis()
QVERIFY(c); QVERIFY(c);
QVERIFY(c->isDecorated()); QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder()); QVERIFY(!c->noBorder());
QCOMPARE(c->titlebarPosition(), AbstractClient::PositionTop); QCOMPARE(c->titlebarPosition(), Qt::TopEdge);
QVERIFY(!c->keepAbove()); QVERIFY(!c->keepAbove());
QVERIFY(!c->keepBelow()); QVERIFY(!c->keepBelow());

@ -679,10 +679,10 @@ void AbstractClient::toggleShade()
setShade(shadeMode() == ShadeNone ? ShadeNormal : ShadeNone); setShade(shadeMode() == ShadeNone ? ShadeNormal : ShadeNone);
} }
AbstractClient::Position AbstractClient::titlebarPosition() const Qt::Edge AbstractClient::titlebarPosition() const
{ {
// TODO: still needed, remove? // TODO: still needed, remove?
return PositionTop; return Qt::TopEdge;
} }
bool AbstractClient::titlebarPositionUnderMouse() const bool AbstractClient::titlebarPositionUnderMouse() const
@ -696,13 +696,13 @@ bool AbstractClient::titlebarPositionUnderMouse() const
} }
// check other sections based on titlebarPosition // check other sections based on titlebarPosition
switch (titlebarPosition()) { switch (titlebarPosition()) {
case AbstractClient::PositionTop: case Qt::TopEdge:
return (sectionUnderMouse == Qt::TopLeftSection || sectionUnderMouse == Qt::TopSection || sectionUnderMouse == Qt::TopRightSection); return (sectionUnderMouse == Qt::TopLeftSection || sectionUnderMouse == Qt::TopSection || sectionUnderMouse == Qt::TopRightSection);
case AbstractClient::PositionLeft: case Qt::LeftEdge:
return (sectionUnderMouse == Qt::TopLeftSection || sectionUnderMouse == Qt::LeftSection || sectionUnderMouse == Qt::BottomLeftSection); return (sectionUnderMouse == Qt::TopLeftSection || sectionUnderMouse == Qt::LeftSection || sectionUnderMouse == Qt::BottomLeftSection);
case AbstractClient::PositionRight: case Qt::RightEdge:
return (sectionUnderMouse == Qt::BottomRightSection || sectionUnderMouse == Qt::RightSection || sectionUnderMouse == Qt::TopRightSection); return (sectionUnderMouse == Qt::BottomRightSection || sectionUnderMouse == Qt::RightSection || sectionUnderMouse == Qt::TopRightSection);
case AbstractClient::PositionBottom: case Qt::BottomEdge:
return (sectionUnderMouse == Qt::BottomLeftSection || sectionUnderMouse == Qt::BottomSection || sectionUnderMouse == Qt::BottomRightSection); return (sectionUnderMouse == Qt::BottomLeftSection || sectionUnderMouse == Qt::BottomSection || sectionUnderMouse == Qt::BottomRightSection);
default: default:
// nothing // nothing
@ -1179,17 +1179,17 @@ void AbstractClient::handleInteractiveMoveResize(int x, int y, int x_root, int y
r.moveTopLeft(QPoint(0,0)); r.moveTopLeft(QPoint(0,0));
switch (titlebarPosition()) { switch (titlebarPosition()) {
default: default:
case PositionTop: case Qt::TopEdge:
r.setHeight(borderTop()); r.setHeight(borderTop());
break; break;
case PositionLeft: case Qt::LeftEdge:
r.setWidth(borderLeft()); r.setWidth(borderLeft());
transposed = true; transposed = true;
break; break;
case PositionBottom: case Qt::BottomEdge:
r.setTop(r.bottom() - borderBottom()); r.setTop(r.bottom() - borderBottom());
break; break;
case PositionRight: case Qt::RightEdge:
r.setLeft(r.right() - borderRight()); r.setLeft(r.right() - borderRight());
transposed = true; transposed = true;
break; break;
@ -1306,16 +1306,16 @@ void AbstractClient::handleInteractiveMoveResize(int x, int y, int x_root, int y
}; };
switch (titlebarPosition()) { switch (titlebarPosition()) {
default: default:
case PositionTop: case Qt::TopEdge:
fixChangedState(topChanged, btmChanged, leftChanged, rightChanged); fixChangedState(topChanged, btmChanged, leftChanged, rightChanged);
break; break;
case PositionLeft: case Qt::LeftEdge:
fixChangedState(leftChanged, rightChanged, topChanged, btmChanged); fixChangedState(leftChanged, rightChanged, topChanged, btmChanged);
break; break;
case PositionBottom: case Qt::BottomEdge:
fixChangedState(btmChanged, topChanged, leftChanged, rightChanged); fixChangedState(btmChanged, topChanged, leftChanged, rightChanged);
break; break;
case PositionRight: case Qt::RightEdge:
fixChangedState(rightChanged, leftChanged, topChanged, btmChanged); fixChangedState(rightChanged, leftChanged, topChanged, btmChanged);
break; break;
} }

@ -616,7 +616,7 @@ public:
PositionBottomLeft = PositionLeft | PositionBottom, PositionBottomLeft = PositionLeft | PositionBottom,
PositionBottomRight = PositionRight | PositionBottom PositionBottomRight = PositionRight | PositionBottom
}; };
Position titlebarPosition() const; Qt::Edge titlebarPosition() const;
bool titlebarPositionUnderMouse() const; bool titlebarPositionUnderMouse() const;
// a helper for the workspace window packing. tests for screen validity and updates since in maximization case as with normal moving // a helper for the workspace window packing. tests for screen validity and updates since in maximization case as with normal moving

@ -106,22 +106,22 @@ void Placement::place(AbstractClient *c, const QRect &area, Policy policy, Polic
const QRect geo(c->moveResizeGeometry()); const QRect geo(c->moveResizeGeometry());
QPoint corner = geo.topLeft(); QPoint corner = geo.topLeft();
const QMargins frameMargins = c->frameMargins(); const QMargins frameMargins = c->frameMargins();
AbstractClient::Position titlePos = c->titlebarPosition(); Qt::Edge titlePos = c->titlebarPosition();
const QRect fullRect = workspace()->clientArea(FullArea, c); const QRect fullRect = workspace()->clientArea(FullArea, c);
if (!(c->maximizeMode() & MaximizeHorizontal)) { if (!(c->maximizeMode() & MaximizeHorizontal)) {
if (titlePos != AbstractClient::PositionRight && geo.right() == fullRect.right()) { if (titlePos != Qt::RightEdge && geo.right() == fullRect.right()) {
corner.rx() += frameMargins.right(); corner.rx() += frameMargins.right();
} }
if (titlePos != AbstractClient::PositionLeft && geo.left() == fullRect.left()) { if (titlePos != Qt::LeftEdge && geo.left() == fullRect.left()) {
corner.rx() -= frameMargins.left(); corner.rx() -= frameMargins.left();
} }
} }
if (!(c->maximizeMode() & MaximizeVertical)) { if (!(c->maximizeMode() & MaximizeVertical)) {
if (titlePos != AbstractClient::PositionBottom && geo.bottom() == fullRect.bottom()) { if (titlePos != Qt::BottomEdge && geo.bottom() == fullRect.bottom()) {
corner.ry() += frameMargins.bottom(); corner.ry() += frameMargins.bottom();
} }
if (titlePos != AbstractClient::PositionTop && geo.top() == fullRect.top()) { if (titlePos != Qt::TopEdge && geo.top() == fullRect.top()) {
corner.ry() -= frameMargins.top(); corner.ry() -= frameMargins.top();
} }
} }
@ -863,7 +863,7 @@ int Workspace::packPositionLeft(const AbstractClient *client, int oldX, bool lef
client, client,
QPoint(client->frameGeometry().left() - 1, client->frameGeometry().center().y())).left(); QPoint(client->frameGeometry().left() - 1, client->frameGeometry().center().y())).left();
} }
if (client->titlebarPosition() != AbstractClient::PositionLeft) { if (client->titlebarPosition() != Qt::LeftEdge) {
const int right = newX - client->frameMargins().left(); const int right = newX - client->frameMargins().left();
QRect frameGeometry = client->frameGeometry(); QRect frameGeometry = client->frameGeometry();
frameGeometry.moveRight(right); frameGeometry.moveRight(right);
@ -897,7 +897,7 @@ int Workspace::packPositionRight(const AbstractClient *client, int oldX, bool ri
client, client,
QPoint(client->frameGeometry().right() + 1, client->frameGeometry().center().y())).right(); QPoint(client->frameGeometry().right() + 1, client->frameGeometry().center().y())).right();
} }
if (client->titlebarPosition() != AbstractClient::PositionRight) { if (client->titlebarPosition() != Qt::RightEdge) {
const int right = newX + client->frameMargins().right(); const int right = newX + client->frameMargins().right();
QRect frameGeometry = client->frameGeometry(); QRect frameGeometry = client->frameGeometry();
frameGeometry.moveRight(right); frameGeometry.moveRight(right);
@ -931,7 +931,7 @@ int Workspace::packPositionUp(const AbstractClient *client, int oldY, bool topEd
client, client,
QPoint(client->frameGeometry().center().x(), client->frameGeometry().top() - 1)).top(); QPoint(client->frameGeometry().center().x(), client->frameGeometry().top() - 1)).top();
} }
if (client->titlebarPosition() != AbstractClient::PositionTop) { if (client->titlebarPosition() != Qt::TopEdge) {
const int top = newY - client->frameMargins().top(); const int top = newY - client->frameMargins().top();
QRect frameGeometry = client->frameGeometry(); QRect frameGeometry = client->frameGeometry();
frameGeometry.moveTop(top); frameGeometry.moveTop(top);
@ -965,7 +965,7 @@ int Workspace::packPositionDown(const AbstractClient *client, int oldY, bool bot
client, client,
QPoint(client->frameGeometry().center().x(), client->frameGeometry().bottom() + 1)).bottom(); QPoint(client->frameGeometry().center().x(), client->frameGeometry().bottom() + 1)).bottom();
} }
if (client->titlebarPosition() != AbstractClient::PositionBottom) { if (client->titlebarPosition() != Qt::BottomEdge) {
const int bottom = newY + client->frameMargins().bottom(); const int bottom = newY + client->frameMargins().bottom();
QRect frameGeometry = client->frameGeometry(); QRect frameGeometry = client->frameGeometry();
frameGeometry.moveBottom(bottom); frameGeometry.moveBottom(bottom);

@ -2495,20 +2495,20 @@ QPoint Workspace::adjustClientPosition(AbstractClient* c, QPoint pos, bool unres
QMargins frameMargins = c->frameMargins(); QMargins frameMargins = c->frameMargins();
// snap to titlebar / snap to window borders on inner screen edges // snap to titlebar / snap to window borders on inner screen edges
AbstractClient::Position titlePos = c->titlebarPosition(); Qt::Edge titlePos = c->titlebarPosition();
if (frameMargins.left() && (titlePos == AbstractClient::PositionLeft || (c->maximizeMode() & MaximizeHorizontal) || if (frameMargins.left() && (titlePos == Qt::LeftEdge || (c->maximizeMode() & MaximizeHorizontal) ||
screens()->intersecting(geo.translated(maxRect.x() - (frameMargins.left() + geo.x()), 0)) > 1)) { screens()->intersecting(geo.translated(maxRect.x() - (frameMargins.left() + geo.x()), 0)) > 1)) {
frameMargins.setLeft(0); frameMargins.setLeft(0);
} }
if (frameMargins.right() && (titlePos == AbstractClient::PositionRight || (c->maximizeMode() & MaximizeHorizontal) || if (frameMargins.right() && (titlePos == Qt::RightEdge || (c->maximizeMode() & MaximizeHorizontal) ||
screens()->intersecting(geo.translated(maxRect.right() + frameMargins.right() - geo.right(), 0)) > 1)) { screens()->intersecting(geo.translated(maxRect.right() + frameMargins.right() - geo.right(), 0)) > 1)) {
frameMargins.setRight(0); frameMargins.setRight(0);
} }
if (frameMargins.top() && (titlePos == AbstractClient::PositionTop || (c->maximizeMode() & MaximizeVertical) || if (frameMargins.top() && (titlePos == Qt::TopEdge || (c->maximizeMode() & MaximizeVertical) ||
screens()->intersecting(geo.translated(0, maxRect.y() - (frameMargins.top() + geo.y()))) > 1)) { screens()->intersecting(geo.translated(0, maxRect.y() - (frameMargins.top() + geo.y()))) > 1)) {
frameMargins.setTop(0); frameMargins.setTop(0);
} }
if (frameMargins.bottom() && (titlePos == AbstractClient::PositionBottom || (c->maximizeMode() & MaximizeVertical) || if (frameMargins.bottom() && (titlePos == Qt::BottomEdge || (c->maximizeMode() & MaximizeVertical) ||
screens()->intersecting(geo.translated(0, maxRect.bottom() + frameMargins.bottom() - geo.bottom())) > 1)) { screens()->intersecting(geo.translated(0, maxRect.bottom() + frameMargins.bottom() - geo.bottom())) > 1)) {
frameMargins.setBottom(0); frameMargins.setBottom(0);
} }

@ -4350,11 +4350,11 @@ void X11Client::changeMaximize(bool horizontal, bool vertical, bool adjust)
const bool overHeight = r.height() > clientArea.height(); const bool overHeight = r.height() > clientArea.height();
const bool overWidth = r.width() > clientArea.width(); const bool overWidth = r.width() > clientArea.width();
if (closeWidth || closeHeight) { if (closeWidth || closeHeight) {
Position titlePos = titlebarPosition(); Qt::Edge titlePos = titlebarPosition();
const QRect screenArea = workspace()->clientArea(ScreenArea, this, clientArea.center()); const QRect screenArea = workspace()->clientArea(ScreenArea, this, clientArea.center());
if (closeHeight) { if (closeHeight) {
bool tryBottom = titlePos == PositionBottom; bool tryBottom = titlePos == Qt::BottomEdge;
if ((overHeight && titlePos == PositionTop) || if ((overHeight && titlePos == Qt::TopEdge) ||
screenArea.top() == clientArea.top()) screenArea.top() == clientArea.top())
r.setTop(clientArea.top()); r.setTop(clientArea.top());
else else
@ -4364,8 +4364,8 @@ void X11Client::changeMaximize(bool horizontal, bool vertical, bool adjust)
r.setBottom(clientArea.bottom()); r.setBottom(clientArea.bottom());
} }
if (closeWidth) { if (closeWidth) {
bool tryLeft = titlePos == PositionLeft; bool tryLeft = titlePos == Qt::LeftEdge;
if ((overWidth && titlePos == PositionRight) || if ((overWidth && titlePos == Qt::RightEdge) ||
screenArea.right() == clientArea.right()) screenArea.right() == clientArea.right())
r.setRight(clientArea.right()); r.setRight(clientArea.right());
else else

Loading…
Cancel
Save