Move Position from KDecorationDefines to Client

icc-effect-5.14.5
Martin Gräßlin 2014-12-02 11:12:20 +01:00
parent e38d56b0dd
commit fa4332754c
4 changed files with 55 additions and 40 deletions

View File

@ -2136,23 +2136,23 @@ Client::Position Client::mousePosition(const QPoint& p) const
if (m_decoration) { if (m_decoration) {
switch (m_decoration->sectionUnderMouse()) { switch (m_decoration->sectionUnderMouse()) {
case Qt::BottomLeftSection: case Qt::BottomLeftSection:
return KDecorationDefines::PositionBottomLeft; return PositionBottomLeft;
case Qt::BottomRightSection: case Qt::BottomRightSection:
return KDecorationDefines::PositionBottomRight; return PositionBottomRight;
case Qt::BottomSection: case Qt::BottomSection:
return KDecorationDefines::PositionBottom; return PositionBottom;
case Qt::LeftSection: case Qt::LeftSection:
return KDecorationDefines::PositionLeft; return PositionLeft;
case Qt::RightSection: case Qt::RightSection:
return KDecorationDefines::PositionRight; return PositionRight;
case Qt::TopSection: case Qt::TopSection:
return KDecorationDefines::PositionTop; return PositionTop;
case Qt::TopLeftSection: case Qt::TopLeftSection:
return KDecorationDefines::PositionTopLeft; return PositionTopLeft;
case Qt::TopRightSection: case Qt::TopRightSection:
return KDecorationDefines::PositionTopRight; return PositionTopRight;
default: default:
return KDecorationDefines::PositionCenter; return PositionCenter;
} }
} }
return PositionCenter; return PositionCenter;
@ -2272,7 +2272,7 @@ QRect Client::decorationRect() const
return QRect(0, 0, width(), height()); return QRect(0, 0, width(), height());
} }
KDecorationDefines::Position Client::titlebarPosition() const Client::Position Client::titlebarPosition() const
{ {
// TODO: still needed, remove? // TODO: still needed, remove?
return PositionTop; return PositionTop;

View File

@ -624,6 +624,21 @@ public:
bool isClientSideDecorated() const; bool isClientSideDecorated() const;
bool wantsShadowToBeRendered() const override; bool wantsShadowToBeRendered() const override;
/**
* These values represent positions inside an area
*/
enum Position {
// without prefix, they'd conflict with Qt::TopLeftCorner etc. :(
PositionCenter = 0x00,
PositionLeft = 0x01,
PositionRight = 0x02,
PositionTop = 0x04,
PositionBottom = 0x08,
PositionTopLeft = PositionLeft | PositionTop,
PositionTopRight = PositionRight | PositionTop,
PositionBottomLeft = PositionLeft | PositionBottom,
PositionBottomRight = PositionRight | PositionBottom
};
Position titlebarPosition() const; Position titlebarPosition() const;
void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const; void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const;

View File

@ -419,17 +419,17 @@ QPoint Workspace::adjustClientPosition(Client* c, QPoint pos, bool unrestricted,
int padding[4] = { cp.x(), cs.width() - cp.x(), cp.y(), cs.height() - cp.y() }; int padding[4] = { cp.x(), cs.width() - cp.x(), cp.y(), cs.height() - cp.y() };
// snap to titlebar / snap to window borders on inner screen edges // snap to titlebar / snap to window borders on inner screen edges
Position titlePos = c->titlebarPosition(); Client::Position titlePos = c->titlebarPosition();
if (padding[0] && (titlePos == PositionLeft || (c->maximizeMode() & MaximizeHorizontal) || if (padding[0] && (titlePos == Client::PositionLeft || (c->maximizeMode() & Client::MaximizeHorizontal) ||
screens()->intersecting(geo.translated(maxRect.x() - (padding[0] + geo.x()), 0)) > 1)) screens()->intersecting(geo.translated(maxRect.x() - (padding[0] + geo.x()), 0)) > 1))
padding[0] = 0; padding[0] = 0;
if (padding[1] && (titlePos == PositionRight || (c->maximizeMode() & MaximizeHorizontal) || if (padding[1] && (titlePos == Client::PositionRight || (c->maximizeMode() & Client::MaximizeHorizontal) ||
screens()->intersecting(geo.translated(maxRect.right() + padding[1] - geo.right(), 0)) > 1)) screens()->intersecting(geo.translated(maxRect.right() + padding[1] - geo.right(), 0)) > 1))
padding[1] = 0; padding[1] = 0;
if (padding[2] && (titlePos == PositionTop || (c->maximizeMode() & MaximizeVertical) || if (padding[2] && (titlePos == Client::PositionTop || (c->maximizeMode() & Client::MaximizeVertical) ||
screens()->intersecting(geo.translated(0, maxRect.y() - (padding[2] + geo.y()))) > 1)) screens()->intersecting(geo.translated(0, maxRect.y() - (padding[2] + geo.y()))) > 1))
padding[2] = 0; padding[2] = 0;
if (padding[3] && (titlePos == PositionBottom || (c->maximizeMode() & MaximizeVertical) || if (padding[3] && (titlePos == Client::PositionBottom || (c->maximizeMode() & Client::MaximizeVertical) ||
screens()->intersecting(geo.translated(0, maxRect.bottom() + padding[3] - geo.bottom())) > 1)) screens()->intersecting(geo.translated(0, maxRect.bottom() + padding[3] - geo.bottom())) > 1))
padding[3] = 0; padding[3] = 0;
if ((sOWO ? (cx < xmin) : true) && (qAbs(xmin - cx) < snapX)) { if ((sOWO ? (cx < xmin) : true) && (qAbs(xmin - cx) < snapX)) {
@ -610,31 +610,31 @@ QRect Workspace::adjustClientSize(Client* c, QRect moveResizeGeom, int mode)
newrx = xmax; \ newrx = xmax; \
} }
switch(mode) { switch(mode) {
case PositionBottomRight: case Client::PositionBottomRight:
SNAP_BORDER_BOTTOM SNAP_BORDER_BOTTOM
SNAP_BORDER_RIGHT SNAP_BORDER_RIGHT
break; break;
case PositionRight: case Client::PositionRight:
SNAP_BORDER_RIGHT SNAP_BORDER_RIGHT
break; break;
case PositionBottom: case Client::PositionBottom:
SNAP_BORDER_BOTTOM SNAP_BORDER_BOTTOM
break; break;
case PositionTopLeft: case Client::PositionTopLeft:
SNAP_BORDER_TOP SNAP_BORDER_TOP
SNAP_BORDER_LEFT SNAP_BORDER_LEFT
break; break;
case PositionLeft: case Client::PositionLeft:
SNAP_BORDER_LEFT SNAP_BORDER_LEFT
break; break;
case PositionTop: case Client::PositionTop:
SNAP_BORDER_TOP SNAP_BORDER_TOP
break; break;
case PositionTopRight: case Client::PositionTopRight:
SNAP_BORDER_TOP SNAP_BORDER_TOP
SNAP_BORDER_RIGHT SNAP_BORDER_RIGHT
break; break;
case PositionBottomLeft: case Client::PositionBottomLeft:
SNAP_BORDER_BOTTOM SNAP_BORDER_BOTTOM
SNAP_BORDER_LEFT SNAP_BORDER_LEFT
break; break;
@ -727,41 +727,41 @@ QRect Workspace::adjustClientSize(Client* c, QRect moveResizeGeom, int mode)
} }
switch(mode) { switch(mode) {
case PositionBottomRight: case Client::PositionBottomRight:
SNAP_WINDOW_BOTTOM SNAP_WINDOW_BOTTOM
SNAP_WINDOW_RIGHT SNAP_WINDOW_RIGHT
SNAP_WINDOW_C_BOTTOM SNAP_WINDOW_C_BOTTOM
SNAP_WINDOW_C_RIGHT SNAP_WINDOW_C_RIGHT
break; break;
case PositionRight: case Client::PositionRight:
SNAP_WINDOW_RIGHT SNAP_WINDOW_RIGHT
SNAP_WINDOW_C_RIGHT SNAP_WINDOW_C_RIGHT
break; break;
case PositionBottom: case Client::PositionBottom:
SNAP_WINDOW_BOTTOM SNAP_WINDOW_BOTTOM
SNAP_WINDOW_C_BOTTOM SNAP_WINDOW_C_BOTTOM
break; break;
case PositionTopLeft: case Client::PositionTopLeft:
SNAP_WINDOW_TOP SNAP_WINDOW_TOP
SNAP_WINDOW_LEFT SNAP_WINDOW_LEFT
SNAP_WINDOW_C_TOP SNAP_WINDOW_C_TOP
SNAP_WINDOW_C_LEFT SNAP_WINDOW_C_LEFT
break; break;
case PositionLeft: case Client::PositionLeft:
SNAP_WINDOW_LEFT SNAP_WINDOW_LEFT
SNAP_WINDOW_C_LEFT SNAP_WINDOW_C_LEFT
break; break;
case PositionTop: case Client::PositionTop:
SNAP_WINDOW_TOP SNAP_WINDOW_TOP
SNAP_WINDOW_C_TOP SNAP_WINDOW_C_TOP
break; break;
case PositionTopRight: case Client::PositionTopRight:
SNAP_WINDOW_TOP SNAP_WINDOW_TOP
SNAP_WINDOW_RIGHT SNAP_WINDOW_RIGHT
SNAP_WINDOW_C_TOP SNAP_WINDOW_C_TOP
SNAP_WINDOW_C_RIGHT SNAP_WINDOW_C_RIGHT
break; break;
case PositionBottomLeft: case Client::PositionBottomLeft:
SNAP_WINDOW_BOTTOM SNAP_WINDOW_BOTTOM
SNAP_WINDOW_LEFT SNAP_WINDOW_LEFT
SNAP_WINDOW_C_BOTTOM SNAP_WINDOW_C_BOTTOM

View File

@ -108,19 +108,19 @@ void Placement::place(Client* c, QRect& area, Policy policy, Policy nextPlacemen
QPoint corner = geo.topLeft(); QPoint corner = geo.topLeft();
const QPoint cp = c->clientPos(); const QPoint cp = c->clientPos();
const QSize cs = geo.size() - c->clientSize(); const QSize cs = geo.size() - c->clientSize();
KDecorationDefines::Position titlePos = c->titlebarPosition(); Client::Position titlePos = c->titlebarPosition();
const QRect fullRect = workspace()->clientArea(FullArea, c); const QRect fullRect = workspace()->clientArea(FullArea, c);
if (!(c->maximizeMode() & KDecorationDefines::MaximizeHorizontal)) { if (!(c->maximizeMode() & KDecorationDefines::MaximizeHorizontal)) {
if (titlePos != KDecorationDefines::PositionRight && geo.right() == fullRect.right()) if (titlePos != Client::PositionRight && geo.right() == fullRect.right())
corner.rx() += cs.width() - cp.x(); corner.rx() += cs.width() - cp.x();
if (titlePos != KDecorationDefines::PositionLeft && geo.x() == fullRect.x()) if (titlePos != Client::PositionLeft && geo.x() == fullRect.x())
corner.rx() -= cp.x(); corner.rx() -= cp.x();
} }
if (!(c->maximizeMode() & KDecorationDefines::MaximizeVertical)) { if (!(c->maximizeMode() & KDecorationDefines::MaximizeVertical)) {
if (titlePos != KDecorationDefines::PositionBottom && geo.bottom() == fullRect.bottom()) if (titlePos != Client::PositionBottom && geo.bottom() == fullRect.bottom())
corner.ry() += cs.height() - cp.y(); corner.ry() += cs.height() - cp.y();
if (titlePos != KDecorationDefines::PositionTop && geo.y() == fullRect.y()) if (titlePos != Client::PositionTop && geo.y() == fullRect.y())
corner.ry() -= cp.y(); corner.ry() -= cp.y();
} }
c->move(corner); c->move(corner);
@ -847,7 +847,7 @@ int Workspace::packPositionLeft(const Client* cl, int oldx, bool left_edge) cons
if (oldx <= newx) // try another Xinerama screen if (oldx <= newx) // try another Xinerama screen
newx = clientArea(MaximizeArea, newx = clientArea(MaximizeArea,
QPoint(cl->geometry().left() - 1, cl->geometry().center().y()), cl->desktop()).left(); QPoint(cl->geometry().left() - 1, cl->geometry().center().y()), cl->desktop()).left();
if (cl->titlebarPosition() != KDecorationDefines::PositionLeft) { if (cl->titlebarPosition() != Client::PositionLeft) {
QRect geo = cl->geometry(); QRect geo = cl->geometry();
int rgt = newx - cl->clientPos().x(); int rgt = newx - cl->clientPos().x();
geo.moveRight(rgt); geo.moveRight(rgt);
@ -874,7 +874,7 @@ int Workspace::packPositionRight(const Client* cl, int oldx, bool right_edge) co
if (oldx >= newx) // try another Xinerama screen if (oldx >= newx) // try another Xinerama screen
newx = clientArea(MaximizeArea, newx = clientArea(MaximizeArea,
QPoint(cl->geometry().right() + 1, cl->geometry().center().y()), cl->desktop()).right(); QPoint(cl->geometry().right() + 1, cl->geometry().center().y()), cl->desktop()).right();
if (cl->titlebarPosition() != KDecorationDefines::PositionRight) { if (cl->titlebarPosition() != Client::PositionRight) {
QRect geo = cl->geometry(); QRect geo = cl->geometry();
int rgt = newx + cl->width() - (cl->clientSize().width() + cl->clientPos().x()); int rgt = newx + cl->width() - (cl->clientSize().width() + cl->clientPos().x());
geo.moveRight(rgt); geo.moveRight(rgt);
@ -901,7 +901,7 @@ int Workspace::packPositionUp(const Client* cl, int oldy, bool top_edge) const
if (oldy <= newy) // try another Xinerama screen if (oldy <= newy) // try another Xinerama screen
newy = clientArea(MaximizeArea, newy = clientArea(MaximizeArea,
QPoint(cl->geometry().center().x(), cl->geometry().top() - 1), cl->desktop()).top(); QPoint(cl->geometry().center().x(), cl->geometry().top() - 1), cl->desktop()).top();
if (cl->titlebarPosition() != KDecorationDefines::PositionTop) { if (cl->titlebarPosition() != Client::PositionTop) {
QRect geo = cl->geometry(); QRect geo = cl->geometry();
int top = newy - cl->clientPos().y(); int top = newy - cl->clientPos().y();
geo.moveTop(top); geo.moveTop(top);
@ -928,7 +928,7 @@ int Workspace::packPositionDown(const Client* cl, int oldy, bool bottom_edge) co
if (oldy >= newy) // try another Xinerama screen if (oldy >= newy) // try another Xinerama screen
newy = clientArea(MaximizeArea, newy = clientArea(MaximizeArea,
QPoint(cl->geometry().center().x(), cl->geometry().bottom() + 1), cl->desktop()).bottom(); QPoint(cl->geometry().center().x(), cl->geometry().bottom() + 1), cl->desktop()).bottom();
if (cl->titlebarPosition() != KDecorationDefines::PositionBottom) { if (cl->titlebarPosition() != Client::PositionBottom) {
QRect geo = cl->geometry(); QRect geo = cl->geometry();
int btm = newy + cl->height() - (cl->clientSize().height() + cl->clientPos().y()); int btm = newy + cl->height() - (cl->clientSize().height() + cl->clientPos().y());
geo.moveBottom(btm); geo.moveBottom(btm);