Move Position from KDecorationDefines to Client
This commit is contained in:
parent
e38d56b0dd
commit
fa4332754c
4 changed files with 55 additions and 40 deletions
20
client.cpp
20
client.cpp
|
@ -2136,23 +2136,23 @@ Client::Position Client::mousePosition(const QPoint& p) const
|
|||
if (m_decoration) {
|
||||
switch (m_decoration->sectionUnderMouse()) {
|
||||
case Qt::BottomLeftSection:
|
||||
return KDecorationDefines::PositionBottomLeft;
|
||||
return PositionBottomLeft;
|
||||
case Qt::BottomRightSection:
|
||||
return KDecorationDefines::PositionBottomRight;
|
||||
return PositionBottomRight;
|
||||
case Qt::BottomSection:
|
||||
return KDecorationDefines::PositionBottom;
|
||||
return PositionBottom;
|
||||
case Qt::LeftSection:
|
||||
return KDecorationDefines::PositionLeft;
|
||||
return PositionLeft;
|
||||
case Qt::RightSection:
|
||||
return KDecorationDefines::PositionRight;
|
||||
return PositionRight;
|
||||
case Qt::TopSection:
|
||||
return KDecorationDefines::PositionTop;
|
||||
return PositionTop;
|
||||
case Qt::TopLeftSection:
|
||||
return KDecorationDefines::PositionTopLeft;
|
||||
return PositionTopLeft;
|
||||
case Qt::TopRightSection:
|
||||
return KDecorationDefines::PositionTopRight;
|
||||
return PositionTopRight;
|
||||
default:
|
||||
return KDecorationDefines::PositionCenter;
|
||||
return PositionCenter;
|
||||
}
|
||||
}
|
||||
return PositionCenter;
|
||||
|
@ -2272,7 +2272,7 @@ QRect Client::decorationRect() const
|
|||
return QRect(0, 0, width(), height());
|
||||
}
|
||||
|
||||
KDecorationDefines::Position Client::titlebarPosition() const
|
||||
Client::Position Client::titlebarPosition() const
|
||||
{
|
||||
// TODO: still needed, remove?
|
||||
return PositionTop;
|
||||
|
|
15
client.h
15
client.h
|
@ -624,6 +624,21 @@ public:
|
|||
bool isClientSideDecorated() const;
|
||||
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;
|
||||
|
||||
void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const;
|
||||
|
|
42
geometry.cpp
42
geometry.cpp
|
@ -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() };
|
||||
|
||||
// snap to titlebar / snap to window borders on inner screen edges
|
||||
Position titlePos = c->titlebarPosition();
|
||||
if (padding[0] && (titlePos == PositionLeft || (c->maximizeMode() & MaximizeHorizontal) ||
|
||||
Client::Position titlePos = c->titlebarPosition();
|
||||
if (padding[0] && (titlePos == Client::PositionLeft || (c->maximizeMode() & Client::MaximizeHorizontal) ||
|
||||
screens()->intersecting(geo.translated(maxRect.x() - (padding[0] + geo.x()), 0)) > 1))
|
||||
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))
|
||||
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))
|
||||
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))
|
||||
padding[3] = 0;
|
||||
if ((sOWO ? (cx < xmin) : true) && (qAbs(xmin - cx) < snapX)) {
|
||||
|
@ -610,31 +610,31 @@ QRect Workspace::adjustClientSize(Client* c, QRect moveResizeGeom, int mode)
|
|||
newrx = xmax; \
|
||||
}
|
||||
switch(mode) {
|
||||
case PositionBottomRight:
|
||||
case Client::PositionBottomRight:
|
||||
SNAP_BORDER_BOTTOM
|
||||
SNAP_BORDER_RIGHT
|
||||
break;
|
||||
case PositionRight:
|
||||
case Client::PositionRight:
|
||||
SNAP_BORDER_RIGHT
|
||||
break;
|
||||
case PositionBottom:
|
||||
case Client::PositionBottom:
|
||||
SNAP_BORDER_BOTTOM
|
||||
break;
|
||||
case PositionTopLeft:
|
||||
case Client::PositionTopLeft:
|
||||
SNAP_BORDER_TOP
|
||||
SNAP_BORDER_LEFT
|
||||
break;
|
||||
case PositionLeft:
|
||||
case Client::PositionLeft:
|
||||
SNAP_BORDER_LEFT
|
||||
break;
|
||||
case PositionTop:
|
||||
case Client::PositionTop:
|
||||
SNAP_BORDER_TOP
|
||||
break;
|
||||
case PositionTopRight:
|
||||
case Client::PositionTopRight:
|
||||
SNAP_BORDER_TOP
|
||||
SNAP_BORDER_RIGHT
|
||||
break;
|
||||
case PositionBottomLeft:
|
||||
case Client::PositionBottomLeft:
|
||||
SNAP_BORDER_BOTTOM
|
||||
SNAP_BORDER_LEFT
|
||||
break;
|
||||
|
@ -727,41 +727,41 @@ QRect Workspace::adjustClientSize(Client* c, QRect moveResizeGeom, int mode)
|
|||
}
|
||||
|
||||
switch(mode) {
|
||||
case PositionBottomRight:
|
||||
case Client::PositionBottomRight:
|
||||
SNAP_WINDOW_BOTTOM
|
||||
SNAP_WINDOW_RIGHT
|
||||
SNAP_WINDOW_C_BOTTOM
|
||||
SNAP_WINDOW_C_RIGHT
|
||||
break;
|
||||
case PositionRight:
|
||||
case Client::PositionRight:
|
||||
SNAP_WINDOW_RIGHT
|
||||
SNAP_WINDOW_C_RIGHT
|
||||
break;
|
||||
case PositionBottom:
|
||||
case Client::PositionBottom:
|
||||
SNAP_WINDOW_BOTTOM
|
||||
SNAP_WINDOW_C_BOTTOM
|
||||
break;
|
||||
case PositionTopLeft:
|
||||
case Client::PositionTopLeft:
|
||||
SNAP_WINDOW_TOP
|
||||
SNAP_WINDOW_LEFT
|
||||
SNAP_WINDOW_C_TOP
|
||||
SNAP_WINDOW_C_LEFT
|
||||
break;
|
||||
case PositionLeft:
|
||||
case Client::PositionLeft:
|
||||
SNAP_WINDOW_LEFT
|
||||
SNAP_WINDOW_C_LEFT
|
||||
break;
|
||||
case PositionTop:
|
||||
case Client::PositionTop:
|
||||
SNAP_WINDOW_TOP
|
||||
SNAP_WINDOW_C_TOP
|
||||
break;
|
||||
case PositionTopRight:
|
||||
case Client::PositionTopRight:
|
||||
SNAP_WINDOW_TOP
|
||||
SNAP_WINDOW_RIGHT
|
||||
SNAP_WINDOW_C_TOP
|
||||
SNAP_WINDOW_C_RIGHT
|
||||
break;
|
||||
case PositionBottomLeft:
|
||||
case Client::PositionBottomLeft:
|
||||
SNAP_WINDOW_BOTTOM
|
||||
SNAP_WINDOW_LEFT
|
||||
SNAP_WINDOW_C_BOTTOM
|
||||
|
|
|
@ -108,19 +108,19 @@ void Placement::place(Client* c, QRect& area, Policy policy, Policy nextPlacemen
|
|||
QPoint corner = geo.topLeft();
|
||||
const QPoint cp = c->clientPos();
|
||||
const QSize cs = geo.size() - c->clientSize();
|
||||
KDecorationDefines::Position titlePos = c->titlebarPosition();
|
||||
Client::Position titlePos = c->titlebarPosition();
|
||||
|
||||
const QRect fullRect = workspace()->clientArea(FullArea, c);
|
||||
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();
|
||||
if (titlePos != KDecorationDefines::PositionLeft && geo.x() == fullRect.x())
|
||||
if (titlePos != Client::PositionLeft && geo.x() == fullRect.x())
|
||||
corner.rx() -= cp.x();
|
||||
}
|
||||
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();
|
||||
if (titlePos != KDecorationDefines::PositionTop && geo.y() == fullRect.y())
|
||||
if (titlePos != Client::PositionTop && geo.y() == fullRect.y())
|
||||
corner.ry() -= cp.y();
|
||||
}
|
||||
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
|
||||
newx = clientArea(MaximizeArea,
|
||||
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();
|
||||
int rgt = newx - cl->clientPos().x();
|
||||
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
|
||||
newx = clientArea(MaximizeArea,
|
||||
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();
|
||||
int rgt = newx + cl->width() - (cl->clientSize().width() + cl->clientPos().x());
|
||||
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
|
||||
newy = clientArea(MaximizeArea,
|
||||
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();
|
||||
int top = newy - cl->clientPos().y();
|
||||
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
|
||||
newy = clientArea(MaximizeArea,
|
||||
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();
|
||||
int btm = newy + cl->height() - (cl->clientSize().height() + cl->clientPos().y());
|
||||
geo.moveBottom(btm);
|
||||
|
|
Loading…
Reference in a new issue