Add setGeometry to AbstractClient as pure virtual method

In Client existing method is marked as override, in ShellClient a new
override is added which delegates to requestGeometry. Existing method
is renamed to doSetGeometry and all internal calls delegat to it.
Needs better merging with the implementation of Client.
remotes/origin/Plasma/5.5
Martin Gräßlin 11 years ago
parent eacaf25acf
commit 696cdb9e39
  1. 12
      abstract_client.h
  2. 14
      client.h
  3. 21
      shell_client.cpp
  4. 4
      shell_client.h

@ -174,6 +174,11 @@ class AbstractClient : public Toplevel
* Whether the Client represents a modal window.
**/
Q_PROPERTY(bool modal READ isModal NOTIFY modalChanged)
/**
* The geometry of this Client. Be aware that depending on resize mode the geometryChanged signal
* might be emitted at each resize step or only at the end of the resize operation.
**/
Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
public:
virtual ~AbstractClient();
@ -398,6 +403,8 @@ public:
void keepInArea(QRect area, bool partial = false);
virtual QSize minSize() const;
virtual QSize maxSize() const;
virtual void setGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet) = 0;
void setGeometry(const QRect& r, ForceGeometry_t force = NormalGeometrySet);
/// How to resize the window in order to obey constains (mainly aspect ratios)
enum Sizemode {
SizemodeAny,
@ -600,6 +607,11 @@ inline void AbstractClient::resizeWithChecks(const QSize& s, AbstractClient::For
resizeWithChecks(s.width(), s.height(), force);
}
inline void AbstractClient::setGeometry(const QRect& r, ForceGeometry_t force)
{
setGeometry(r.x(), r.y(), r.width(), r.height(), force);
}
inline const QList<AbstractClient*>& AbstractClient::transients() const
{
return m_transients;

@ -75,11 +75,6 @@ class Client
: public AbstractClient
{
Q_OBJECT
/**
* The geometry of this Client. Be aware that depending on resize mode the geometryChanged signal
* might be emitted at each resize step or only at the end of the resize operation.
**/
Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
/**
* Whether the Client can be maximized both horizontally and vertically.
* The property is evaluated each time it is invoked.
@ -270,8 +265,8 @@ public:
void updateShape();
void setGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet);
void setGeometry(const QRect& r, ForceGeometry_t force = NormalGeometrySet);
using AbstractClient::setGeometry;
void setGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet) override;
using AbstractClient::move;
void move(int x, int y, ForceGeometry_t force = NormalGeometrySet) override;
/// plainResize() simply resizes
@ -890,11 +885,6 @@ inline QSize Client::clientSize() const
return client_size;
}
inline void Client::setGeometry(const QRect& r, ForceGeometry_t force)
{
setGeometry(r.x(), r.y(), r.width(), r.height(), force);
}
inline void Client::plainResize(const QSize& s, ForceGeometry_t force)
{
plainResize(s.width(), s.height(), force);

@ -64,7 +64,7 @@ ShellClient::ShellClient(ShellSurfaceInterface *surface)
updateInternalWindowGeometry();
setOnAllDesktops(true);
} else {
setGeometry(QRect(QPoint(0, 0), m_clientSize));
doSetGeometry(QRect(QPoint(0, 0), m_clientSize));
setDesktop(VirtualDesktopManager::self()->current());
}
if (waylandServer()->inputMethodConnection() == m_shellSurface->client()) {
@ -74,7 +74,7 @@ ShellClient::ShellClient(ShellSurfaceInterface *surface)
connect(surface->surface(), &SurfaceInterface::sizeChanged, this,
[this] {
m_clientSize = m_shellSurface->surface()->buffer()->size();
setGeometry(QRect(geom.topLeft(), m_clientSize));
doSetGeometry(QRect(geom.topLeft(), m_clientSize));
discardWindowPixmap();
}
);
@ -220,7 +220,7 @@ void ShellClient::addDamage(const QRegion &damage)
position = m_positionAfterResize.point();
m_positionAfterResize.clear();
}
setGeometry(QRect(position, m_clientSize));
doSetGeometry(QRect(position, m_clientSize));
}
markAsMapped();
setDepth(m_shellSurface->surface()->buffer()->hasAlphaChannel() ? 32 : 24);
@ -235,7 +235,7 @@ void ShellClient::setInternalFramebufferObject(const QSharedPointer<QOpenGLFrame
}
markAsMapped();
m_clientSize = fbo->size();
setGeometry(QRect(geom.topLeft(), m_clientSize));
doSetGeometry(QRect(geom.topLeft(), m_clientSize));
Toplevel::setInternalFramebufferObject(fbo);
Toplevel::addDamage(QRegion(0, 0, width(), height()));
}
@ -250,7 +250,14 @@ void ShellClient::markAsMapped()
setupWindowManagementInterface();
}
void ShellClient::setGeometry(const QRect &rect)
void ShellClient::setGeometry(int x, int y, int w, int h, ForceGeometry_t force)
{
Q_UNUSED(force)
// TODO: better merge with Client's implementation
requestGeometry(QRect(x, y, w, h));
}
void ShellClient::doSetGeometry(const QRect &rect)
{
if (geom == rect) {
return;
@ -549,7 +556,7 @@ void ShellClient::updateInternalWindowGeometry()
if (!m_internalWindow) {
return;
}
setGeometry(m_internalWindow->geometry());
doSetGeometry(m_internalWindow->geometry());
}
bool ShellClient::isInternal() const
@ -639,7 +646,7 @@ void ShellClient::installPlasmaShellSurface(PlasmaShellSurfaceInterface *surface
{
m_plasmaShellSurface = surface;
auto updatePosition = [this, surface] {
setGeometry(QRect(surface->position(), m_clientSize));
doSetGeometry(QRect(surface->position(), m_clientSize));
};
auto updateRole = [this, surface] {
NET::WindowType type = NET::Unknown;

@ -95,6 +95,8 @@ public:
void move(int x, int y, ForceGeometry_t force = NormalGeometrySet) override;
using AbstractClient::resizeWithChecks;
void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) override;
using AbstractClient::setGeometry;
void setGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet) override;
bool hasStrut() const override;
void setInternalFramebufferObject(const QSharedPointer<QOpenGLFramebufferObject> &fbo) override;
@ -128,7 +130,7 @@ private Q_SLOTS:
private:
void requestGeometry(const QRect &rect);
void setGeometry(const QRect &rect);
void doSetGeometry(const QRect &rect);
void destroyClient();
void unmap();
void createWindowId();

Loading…
Cancel
Save