Move keepInArea to AbstractClient
This commit is contained in:
parent
007e1253c6
commit
737ad0b664
4 changed files with 30 additions and 31 deletions
|
@ -419,4 +419,33 @@ void AbstractClient::handlePaletteChange()
|
|||
emit paletteChanged(palette());
|
||||
}
|
||||
|
||||
void AbstractClient::keepInArea(QRect area, bool partial)
|
||||
{
|
||||
if (partial) {
|
||||
// increase the area so that can have only 100 pixels in the area
|
||||
area.setLeft(qMin(area.left() - width() + 100, area.left()));
|
||||
area.setTop(qMin(area.top() - height() + 100, area.top()));
|
||||
area.setRight(qMax(area.right() + width() - 100, area.right()));
|
||||
area.setBottom(qMax(area.bottom() + height() - 100, area.bottom()));
|
||||
}
|
||||
if (!partial) {
|
||||
// resize to fit into area
|
||||
if (area.width() < width() || area.height() < height())
|
||||
resizeWithChecks(qMin(area.width(), width()), qMin(area.height(), height()));
|
||||
}
|
||||
int tx = x(), ty = y();
|
||||
if (geometry().right() > area.right() && width() <= area.width())
|
||||
tx = area.right() - width() + 1;
|
||||
if (geometry().bottom() > area.bottom() && height() <= area.height())
|
||||
ty = area.bottom() - height() + 1;
|
||||
if (!area.contains(geometry().topLeft())) {
|
||||
if (tx < area.x())
|
||||
tx = area.x();
|
||||
if (ty < area.y())
|
||||
ty = area.y();
|
||||
}
|
||||
if (tx != x() || ty != y())
|
||||
move(tx, ty);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -310,6 +310,7 @@ public:
|
|||
void move(const QPoint &p, ForceGeometry_t force = NormalGeometrySet);
|
||||
virtual void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) = 0;
|
||||
void resizeWithChecks(const QSize& s, ForceGeometry_t force = NormalGeometrySet);
|
||||
void keepInArea(QRect area, bool partial = false);
|
||||
|
||||
// TODO: remove boolean trap
|
||||
static bool belongToSameApplication(const AbstractClient* c1, const AbstractClient* c2, bool active_hack = false);
|
||||
|
|
1
client.h
1
client.h
|
@ -342,7 +342,6 @@ public:
|
|||
void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) override;
|
||||
void resizeWithChecks(int w, int h, xcb_gravity_t gravity, ForceGeometry_t force = NormalGeometrySet);
|
||||
void resizeWithChecks(const QSize& s, xcb_gravity_t gravity, ForceGeometry_t force = NormalGeometrySet);
|
||||
void keepInArea(QRect area, bool partial = false);
|
||||
void setElectricBorderMode(QuickTileMode mode);
|
||||
QuickTileMode electricBorderMode() const;
|
||||
void setElectricBorderMaximizing(bool maximizing);
|
||||
|
|
30
geometry.cpp
30
geometry.cpp
|
@ -825,36 +825,6 @@ void Workspace::fixPositionAfterCrash(xcb_window_t w, const xcb_get_geometry_rep
|
|||
// Client
|
||||
//********************************************
|
||||
|
||||
|
||||
void Client::keepInArea(QRect area, bool partial)
|
||||
{
|
||||
if (partial) {
|
||||
// increase the area so that can have only 100 pixels in the area
|
||||
area.setLeft(qMin(area.left() - width() + 100, area.left()));
|
||||
area.setTop(qMin(area.top() - height() + 100, area.top()));
|
||||
area.setRight(qMax(area.right() + width() - 100, area.right()));
|
||||
area.setBottom(qMax(area.bottom() + height() - 100, area.bottom()));
|
||||
}
|
||||
if (!partial) {
|
||||
// resize to fit into area
|
||||
if (area.width() < width() || area.height() < height())
|
||||
resizeWithChecks(qMin(area.width(), width()), qMin(area.height(), height()));
|
||||
}
|
||||
int tx = x(), ty = y();
|
||||
if (geometry().right() > area.right() && width() <= area.width())
|
||||
tx = area.right() - width() + 1;
|
||||
if (geometry().bottom() > area.bottom() && height() <= area.height())
|
||||
ty = area.bottom() - height() + 1;
|
||||
if (!area.contains(geometry().topLeft())) {
|
||||
if (tx < area.x())
|
||||
tx = area.x();
|
||||
if (ty < area.y())
|
||||
ty = area.y();
|
||||
}
|
||||
if (tx != x() || ty != y())
|
||||
move(tx, ty);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \a area with the client's strut taken into account.
|
||||
|
||||
|
|
Loading…
Reference in a new issue