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. * Whether the Client represents a modal window.
**/ **/
Q_PROPERTY(bool modal READ isModal NOTIFY modalChanged) 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: public:
virtual ~AbstractClient(); virtual ~AbstractClient();
@ -398,6 +403,8 @@ public:
void keepInArea(QRect area, bool partial = false); void keepInArea(QRect area, bool partial = false);
virtual QSize minSize() const; virtual QSize minSize() const;
virtual QSize maxSize() 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) /// How to resize the window in order to obey constains (mainly aspect ratios)
enum Sizemode { enum Sizemode {
SizemodeAny, SizemodeAny,
@ -600,6 +607,11 @@ inline void AbstractClient::resizeWithChecks(const QSize& s, AbstractClient::For
resizeWithChecks(s.width(), s.height(), force); 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 inline const QList<AbstractClient*>& AbstractClient::transients() const
{ {
return m_transients; return m_transients;

@ -75,11 +75,6 @@ class Client
: public AbstractClient : public AbstractClient
{ {
Q_OBJECT 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. * Whether the Client can be maximized both horizontally and vertically.
* The property is evaluated each time it is invoked. * The property is evaluated each time it is invoked.
@ -270,8 +265,8 @@ public:
void updateShape(); void updateShape();
void setGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet); using AbstractClient::setGeometry;
void setGeometry(const QRect& r, ForceGeometry_t force = NormalGeometrySet); void setGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet) override;
using AbstractClient::move; using AbstractClient::move;
void move(int x, int y, ForceGeometry_t force = NormalGeometrySet) override; void move(int x, int y, ForceGeometry_t force = NormalGeometrySet) override;
/// plainResize() simply resizes /// plainResize() simply resizes
@ -890,11 +885,6 @@ inline QSize Client::clientSize() const
return client_size; 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) inline void Client::plainResize(const QSize& s, ForceGeometry_t force)
{ {
plainResize(s.width(), s.height(), force); plainResize(s.width(), s.height(), force);

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

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

Loading…
Cancel
Save