aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Zagorodniy <[email protected]>2019-01-07 18:29:00 +0200
committerVlad Zagorodniy <[email protected]>2019-01-07 21:40:45 +0200
commitef7b553cb4e036463b4ad5762a997ff52f92ce8b (patch)
treefc0d9bb27970279f7ef8b65b1d0d2a413449e77d
parent3f13a493c8def6978f596f75c22fa7121dc896ab (diff)
[libkwineffects] Port the remaining bits of API to dynamic dispatch
Summary: 7834bec52a6770b16087be07a94cca6a165482a6 missed to port minimize and unminimize to dynamic dispatch. In addition to that, we don't benefit from QMetaObject::invokeMethod so port addRepaint and addLayerRepaint to dynamic dispatch as well. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: davidedmundson, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D18049
-rw-r--r--autotests/test_window_paint_data.cpp50
-rw-r--r--effects.cpp46
-rw-r--r--effects.h10
-rw-r--r--libkwineffects/kwineffects.cpp44
-rw-r--r--libkwineffects/kwineffects.h16
5 files changed, 114 insertions, 52 deletions
diff --git a/autotests/test_window_paint_data.cpp b/autotests/test_window_paint_data.cpp
index 24974f3..167b6d0 100644
--- a/autotests/test_window_paint_data.cpp
+++ b/autotests/test_window_paint_data.cpp
@@ -40,6 +40,11 @@ public:
void deleteProperty(long int atom) const override;
void disablePainting(int reason) override;
void enablePainting(int reason) override;
+ void addRepaint(const QRect &r) override;
+ void addRepaint(int x, int y, int w, int h) override;
+ void addRepaintFull() override;
+ void addLayerRepaint(const QRect &r) override;
+ void addLayerRepaint(int x, int y, int w, int h) override;
EffectWindow *findModal() override;
const EffectWindowGroup *group() const override;
bool isPaintingEnabled() override;
@@ -49,6 +54,9 @@ public:
void unrefWindow() override;
QRegion shape() const override;
void setData(int role, const QVariant &data) override;
+ void minimize() override;
+ void unminimize() override;
+ void closeWindow() override;
void referencePreviousWindowPixmap() override {}
void unreferencePreviousWindowPixmap() override {}
bool isDeleted() const override {
@@ -279,6 +287,36 @@ void MockEffectWindow::enablePainting(int reason)
Q_UNUSED(reason)
}
+void MockEffectWindow::addRepaint(const QRect &r)
+{
+ Q_UNUSED(r)
+}
+
+void MockEffectWindow::addRepaint(int x, int y, int w, int h)
+{
+ Q_UNUSED(x)
+ Q_UNUSED(y)
+ Q_UNUSED(w)
+ Q_UNUSED(h)
+}
+
+void MockEffectWindow::addRepaintFull()
+{
+}
+
+void MockEffectWindow::addLayerRepaint(const QRect &r)
+{
+ Q_UNUSED(r)
+}
+
+void MockEffectWindow::addLayerRepaint(int x, int y, int w, int h)
+{
+ Q_UNUSED(x)
+ Q_UNUSED(y)
+ Q_UNUSED(w)
+ Q_UNUSED(h)
+}
+
EffectWindow *MockEffectWindow::findModal()
{
return nullptr;
@@ -317,6 +355,18 @@ void MockEffectWindow::setData(int role, const QVariant &data)
Q_UNUSED(data)
}
+void MockEffectWindow::minimize()
+{
+}
+
+void MockEffectWindow::unminimize()
+{
+}
+
+void MockEffectWindow::closeWindow()
+{
+}
+
QRegion MockEffectWindow::shape() const
{
return QRegion();
diff --git a/effects.cpp b/effects.cpp
index 0d5044c..42a1efa 100644
--- a/effects.cpp
+++ b/effects.cpp
@@ -1719,6 +1719,31 @@ void EffectWindowImpl::disablePainting(int reason)
sceneWindow()->disablePainting(reason);
}
+void EffectWindowImpl::addRepaint(const QRect &r)
+{
+ toplevel->addRepaint(r);
+}
+
+void EffectWindowImpl::addRepaint(int x, int y, int w, int h)
+{
+ toplevel->addRepaint(x, y, w, h);
+}
+
+void EffectWindowImpl::addRepaintFull()
+{
+ toplevel->addRepaintFull();
+}
+
+void EffectWindowImpl::addLayerRepaint(const QRect &r)
+{
+ toplevel->addLayerRepaint(r);
+}
+
+void EffectWindowImpl::addLayerRepaint(int x, int y, int w, int h)
+{
+ toplevel->addLayerRepaint(x, y, w, h);
+}
+
const EffectWindowGroup* EffectWindowImpl::group() const
{
if (auto c = qobject_cast<Client *>(toplevel)) {
@@ -2012,6 +2037,27 @@ void EffectWindowImpl::desktopThumbnailDestroyed(QObject *object)
m_desktopThumbnails.removeAll(static_cast<DesktopThumbnailItem*>(object));
}
+void EffectWindowImpl::minimize()
+{
+ if (auto client = qobject_cast<AbstractClient *>(toplevel)) {
+ client->minimize();
+ }
+}
+
+void EffectWindowImpl::unminimize()
+{
+ if (auto client = qobject_cast<AbstractClient *>(toplevel)) {
+ client->unminimize();
+ }
+}
+
+void EffectWindowImpl::closeWindow()
+{
+ if (auto client = qobject_cast<AbstractClient *>(toplevel)) {
+ client->closeWindow();
+ }
+}
+
void EffectWindowImpl::referencePreviousWindowPixmap()
{
if (sw) {
diff --git a/effects.h b/effects.h
index e25e1b1..17db6c0 100644
--- a/effects.h
+++ b/effects.h
@@ -374,6 +374,12 @@ public:
void disablePainting(int reason) override;
bool isPaintingEnabled() override;
+ void addRepaint(const QRect &r) override;
+ void addRepaint(int x, int y, int w, int h) override;
+ void addRepaintFull() override;
+ void addLayerRepaint(const QRect &r) override;
+ void addLayerRepaint(int x, int y, int w, int h) override;
+
void refWindow() override;
void unrefWindow() override;
@@ -461,6 +467,10 @@ public:
WindowQuadList buildQuads(bool force = false) const override;
+ void minimize() override;
+ void unminimize() override;
+ void closeWindow() override;
+
void referencePreviousWindowPixmap() override;
void unreferencePreviousWindowPixmap() override;
diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp
index 8b5345b..8f70ba1 100644
--- a/libkwineffects/kwineffects.cpp
+++ b/libkwineffects/kwineffects.cpp
@@ -803,20 +803,6 @@ bool EffectWindow::isOnAllActivities() const
return activities().isEmpty();
}
-#define WINDOW_HELPER_SETTER( prototype, propertyname, args, value ) \
- void EffectWindow::prototype ( args ) \
- {\
- const QVariant variant = parent()->property( propertyname ); \
- if (variant.isValid()) { \
- parent()->setProperty( propertyname, value ); \
- } \
- }
-
-WINDOW_HELPER_SETTER(minimize, "minimized",,true)
-WINDOW_HELPER_SETTER(unminimize, "minimized",,false)
-
-#undef WINDOW_HELPER_SETTER
-
void EffectWindow::setMinimized(bool min)
{
if (min) {
@@ -826,36 +812,6 @@ void EffectWindow::setMinimized(bool min)
}
}
-void EffectWindow::closeWindow() const
-{
- QMetaObject::invokeMethod(parent(), "closeWindow");
-}
-
-void EffectWindow::addRepaint(int x, int y, int w, int h)
-{
- QMetaObject::invokeMethod(parent(), "addRepaint", Q_ARG(int, x), Q_ARG(int, y), Q_ARG(int, w), Q_ARG(int, h));
-}
-
-void EffectWindow::addRepaint(const QRect &r)
-{
- QMetaObject::invokeMethod(parent(), "addRepaint", Q_ARG(const QRect&, r));
-}
-
-void EffectWindow::addRepaintFull()
-{
- QMetaObject::invokeMethod(parent(), "addRepaintFull");
-}
-
-void EffectWindow::addLayerRepaint(int x, int y, int w, int h)
-{
- QMetaObject::invokeMethod(parent(), "addLayerRepaint", Q_ARG(int, x), Q_ARG(int, y), Q_ARG(int, w), Q_ARG(int, h));
-}
-
-void EffectWindow::addLayerRepaint(const QRect &r)
-{
- QMetaObject::invokeMethod(parent(), "addLayerRepaint", Q_ARG(const QRect&, r));
-}
-
bool EffectWindow::isOnCurrentActivity() const
{
return isOnActivity(effects->currentActivity());
diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h
index d3b4522..a2364be 100644
--- a/libkwineffects/kwineffects.h
+++ b/libkwineffects/kwineffects.h
@@ -2063,11 +2063,11 @@ public:
virtual void enablePainting(int reason) = 0;
virtual void disablePainting(int reason) = 0;
virtual bool isPaintingEnabled() = 0;
- Q_SCRIPTABLE void addRepaint(const QRect& r);
- Q_SCRIPTABLE void addRepaint(int x, int y, int w, int h);
- Q_SCRIPTABLE void addRepaintFull();
- Q_SCRIPTABLE void addLayerRepaint(const QRect& r);
- Q_SCRIPTABLE void addLayerRepaint(int x, int y, int w, int h);
+ Q_SCRIPTABLE virtual void addRepaint(const QRect &r) = 0;
+ Q_SCRIPTABLE virtual void addRepaint(int x, int y, int w, int h) = 0;
+ Q_SCRIPTABLE virtual void addRepaintFull() = 0;
+ Q_SCRIPTABLE virtual void addLayerRepaint(const QRect &r) = 0;
+ Q_SCRIPTABLE virtual void addLayerRepaint(int x, int y, int w, int h) = 0;
virtual void refWindow() = 0;
virtual void unrefWindow() = 0;
@@ -2277,9 +2277,9 @@ public:
virtual WindowQuadList buildQuads(bool force = false) const = 0;
void setMinimized(bool minimize);
- void minimize();
- void unminimize();
- Q_SCRIPTABLE void closeWindow() const;
+ virtual void minimize() = 0;
+ virtual void unminimize() = 0;
+ Q_SCRIPTABLE virtual void closeWindow() = 0;
virtual bool isCurrentTab() const = 0;