From da2731be511b380033997b71b9b26172f85ab817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 27 May 2015 10:16:46 +0200 Subject: [PATCH] Move Client::move to AbstractClient and add implementation in ShellClient --- abstract_client.h | 9 +++++++++ client.h | 10 ++-------- shell_client.cpp | 24 ++++++++++++++++++++++++ shell_client.h | 2 ++ 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/abstract_client.h b/abstract_client.h index 42511e62cb..f68bdd0bdb 100644 --- a/abstract_client.h +++ b/abstract_client.h @@ -305,6 +305,10 @@ public: virtual void setQuickTileMode(QuickTileMode mode, bool keyboard = false) = 0; virtual void updateLayer(); + enum ForceGeometry_t { NormalGeometrySet, ForceGeometrySet }; + virtual void move(int x, int y, ForceGeometry_t force = NormalGeometrySet) = 0; + void move(const QPoint &p, ForceGeometry_t force = NormalGeometrySet); + // TODO: remove boolean trap static bool belongToSameApplication(const AbstractClient* c1, const AbstractClient* c2, bool active_hack = false); @@ -401,6 +405,11 @@ private: static std::shared_ptr s_defaultPalette; }; +inline void AbstractClient::move(const QPoint& p, ForceGeometry_t force) +{ + move(p.x(), p.y(), force); +} + } Q_DECLARE_METATYPE(KWin::AbstractClient*) diff --git a/client.h b/client.h index 454dc887c4..affe6796e4 100644 --- a/client.h +++ b/client.h @@ -330,11 +330,10 @@ public: void updateShape(); - enum ForceGeometry_t { NormalGeometrySet, ForceGeometrySet }; void setGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet); void setGeometry(const QRect& r, ForceGeometry_t force = NormalGeometrySet); - void move(int x, int y, ForceGeometry_t force = NormalGeometrySet); - void move(const QPoint& p, ForceGeometry_t force = NormalGeometrySet); + using AbstractClient::move; + void move(int x, int y, ForceGeometry_t force = NormalGeometrySet) override; /// plainResize() simply resizes void plainResize(int w, int h, ForceGeometry_t force = NormalGeometrySet); void plainResize(const QSize& s, ForceGeometry_t force = NormalGeometrySet); @@ -1004,11 +1003,6 @@ inline void Client::setGeometry(const QRect& r, ForceGeometry_t force) setGeometry(r.x(), r.y(), r.width(), r.height(), force); } -inline void Client::move(const QPoint& p, ForceGeometry_t force) -{ - move(p.x(), p.y(), force); -} - inline void Client::plainResize(const QSize& s, ForceGeometry_t force) { plainResize(s.width(), s.height(), force); diff --git a/shell_client.cpp b/shell_client.cpp index 62d6caef50..2ac63a5c73 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -18,8 +18,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "shell_client.h" +#include "composite.h" #include "deleted.h" +#include "screens.h" #include "wayland_server.h" +#include "workspace.h" #include "virtualdesktops.h" #include @@ -397,4 +400,25 @@ xcb_window_t ShellClient::window() const return windowId(); } +void ShellClient::move(int x, int y, ForceGeometry_t force) +{ + QPoint p(x, y); + if (force == NormalGeometrySet && geom.topLeft() == p) { + return; + } + const QRect oldGeom = visibleRect(); + geom.moveTopLeft(p); + updateWindowRules(Rules::Position); + screens()->setCurrent(this); + workspace()->updateStackingOrder(); + if (Compositor::isCreated()) { + // TODO: is this really needed here? + Compositor::self()->checkUnredirect(); + } + + addLayerRepaint(oldGeom); + addLayerRepaint(visibleRect()); + emit geometryChanged(); +} + } diff --git a/shell_client.h b/shell_client.h index 31142b8431..236325617e 100644 --- a/shell_client.h +++ b/shell_client.h @@ -88,6 +88,8 @@ public: bool userCanSetNoBorder() const override; bool wantsInput() const override; xcb_window_t window() const override; + using AbstractClient::move; + void move(int x, int y, ForceGeometry_t force = NormalGeometrySet) override; quint32 windowId() const { return m_windowId;