refactor: Minimize use of geom in Toplevel subclasses

Summary:
This change makes easier to refactor geometry handling in the future.
The main motivation for avoiding using geom directly is to make code
more readable and ensure that the geometry is updated only through
designated methods, e.g. setGeometry, plainResize, etc.

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23072
icc-effect-5.17.5
Vlad Zagorodniy 2019-08-10 17:31:06 +03:00
parent 00daa8a07e
commit 744e2be3f6
2 changed files with 13 additions and 12 deletions

View File

@ -889,7 +889,7 @@ void AbstractClient::setupWindowManagementInterface()
w->setMovable(isMovable());
w->setVirtualDesktopChangeable(true); // FIXME Matches Client::actionSupported(), but both should be implemented.
w->setParentWindow(transientFor() ? transientFor()->windowManagementInterface() : nullptr);
w->setGeometry(geom);
w->setGeometry(geometry());
connect(this, &AbstractClient::skipTaskbarChanged, w,
[w, this] {
w->setSkipTaskbar(skipTaskbar());
@ -929,7 +929,7 @@ void AbstractClient::setupWindowManagementInterface()
);
connect(this, &AbstractClient::geometryChanged, w,
[w, this] {
w->setGeometry(geom);
w->setGeometry(geometry());
}
);
connect(w, &PlasmaWindowInterface::closeRequested, this, [this] { closeWindow(); });
@ -1402,7 +1402,7 @@ void AbstractClient::addRepaintDuringGeometryUpdates()
void AbstractClient::updateGeometryBeforeUpdateBlocking()
{
m_geometryBeforeUpdateBlocking = geom;
m_geometryBeforeUpdateBlocking = geometry();
}
void AbstractClient::updateTabGroupStates(TabGroup::States)

View File

@ -238,7 +238,7 @@ void ShellClient::init()
connect(s, &SurfaceInterface::sizeChanged, this,
[this] {
m_clientSize = surface()->size();
doSetGeometry(QRect(geom.topLeft(), m_clientSize + QSize(borderLeft() + borderRight(), borderTop() + borderBottom())));
doSetGeometry(QRect(pos(), m_clientSize + QSize(borderLeft() + borderRight(), borderTop() + borderBottom())));
}
);
connect(s, &SurfaceInterface::unmapped, this, &ShellClient::unmap);
@ -1231,7 +1231,7 @@ bool ShellClient::requestGeometry(const QRect &rect)
void ShellClient::updatePendingGeometry()
{
QPoint position = geom.topLeft();
QPoint position = pos();
MaximizeMode maximizeMode = m_maximizeMode;
for (auto it = m_pendingConfigureRequests.begin(); it != m_pendingConfigureRequests.end(); it++) {
if (it->serialId > m_lastAckedConfigureRequest) {
@ -1389,19 +1389,20 @@ void ShellClient::updateShowOnScreenEdge()
if ((m_plasmaShellSurface->panelBehavior() == PlasmaShellSurfaceInterface::PanelBehavior::AutoHide && m_hidden) ||
m_plasmaShellSurface->panelBehavior() == PlasmaShellSurfaceInterface::PanelBehavior::WindowsCanCover) {
// screen edge API requires an edge, thus we need to figure out which edge the window borders
const QRect clientGeometry = geometry();
Qt::Edges edges;
for (int i = 0; i < screens()->count(); i++) {
const auto &screenGeo = screens()->geometry(i);
if (screenGeo.x() == geom.x()) {
const QRect screenGeometry = screens()->geometry(i);
if (screenGeometry.left() == clientGeometry.left()) {
edges |= Qt::LeftEdge;
}
if (screenGeo.x() + screenGeo.width() == geom.x() + geom.width()) {
if (screenGeometry.right() == clientGeometry.right()) {
edges |= Qt::RightEdge;
}
if (screenGeo.y() == geom.y()) {
if (screenGeometry.top() == clientGeometry.top()) {
edges |= Qt::TopEdge;
}
if (screenGeo.y() + screenGeo.height() == geom.y() + geom.height()) {
if (screenGeometry.bottom() == clientGeometry.bottom()) {
edges |= Qt::BottomEdge;
}
}
@ -1416,9 +1417,9 @@ void ShellClient::updateShowOnScreenEdge()
}
// it's still possible that a panel borders two edges, e.g. bottom and left
// in that case the one which is sharing more with the edge wins
auto check = [this](Qt::Edges edges, Qt::Edge horiz, Qt::Edge vert) {
auto check = [clientGeometry](Qt::Edges edges, Qt::Edge horiz, Qt::Edge vert) {
if (edges.testFlag(horiz) && edges.testFlag(vert)) {
if (geom.width() >= geom.height()) {
if (clientGeometry.width() >= clientGeometry.height()) {
return edges & ~horiz;
} else {
return edges & ~vert;