From 6f39d79d72b241e6da1ed9129c0138897af1ae3f Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 19 May 2021 09:22:05 +0300 Subject: [PATCH] Remove Scene::Window::{discard,update}Pixmap They are used only by X11Client, so make X11Client call relevants methods on the surface item directly instead. In hindsight, it will be a really good idea to make SurfaceItemX11 and SurfaceItemXwayland(?) automatically manage the window pixmap. However, it can be done once an item freezing api is added and we fix the cross-fade animation. --- src/abstract_client.cpp | 2 -- src/scene.cpp | 34 ---------------------------------- src/scene.h | 6 ------ src/surfaceitem.h | 6 +++--- src/toplevel.cpp | 6 ------ src/toplevel.h | 1 - src/x11client.cpp | 12 ++++++++++-- src/x11client.h | 1 + 8 files changed, 14 insertions(+), 54 deletions(-) diff --git a/src/abstract_client.cpp b/src/abstract_client.cpp index f2cec92537..453f0d1899 100644 --- a/src/abstract_client.cpp +++ b/src/abstract_client.cpp @@ -607,8 +607,6 @@ void AbstractClient::setShade(ShadeMode mode) GeometryUpdatesBlocker blocker(this); doSetShade(previousShadeMode); - - discardWindowPixmap(); updateWindowRules(Rules::Shade); emit shadeChanged(); diff --git a/src/scene.cpp b/src/scene.cpp index 6841a73920..4f64bea720 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -824,40 +824,6 @@ void Scene::Window::unreferencePreviousPixmap_helper(SurfaceItem *item) } } -void Scene::Window::discardPixmap() -{ - if (surfaceItem()) { - discardPixmap_helper(surfaceItem()); - } -} - -void Scene::Window::discardPixmap_helper(SurfaceItem *item) -{ - item->discardPixmap(); - - const QList children = item->childItems(); - for (Item *child : children) { - discardPixmap_helper(static_cast(child)); - } -} - -void Scene::Window::updatePixmap() -{ - if (surfaceItem()) { - updatePixmap_helper(surfaceItem()); - } -} - -void Scene::Window::updatePixmap_helper(SurfaceItem *item) -{ - item->updatePixmap(); - - const QList children = item->childItems(); - for (Item *child : children) { - updatePixmap_helper(static_cast(child)); - } -} - QRegion Scene::Window::decorationShape() const { return QRegion(toplevel->rect()) - toplevel->transparentRect(); diff --git a/src/scene.h b/src/scene.h index 7954e7672e..2a7dc42832 100644 --- a/src/scene.h +++ b/src/scene.h @@ -311,9 +311,6 @@ public: ~Window() override; // perform the actual painting of the window virtual void performPaint(int mask, const QRegion ®ion, const WindowPaintData &data) = 0; - // do any cleanup needed when the window's composite pixmap is discarded - void discardPixmap(); - void updatePixmap(); int x() const; int y() const; int width() const; @@ -374,9 +371,6 @@ protected: Toplevel* toplevel; ImageFilterType filter; private: - void discardPixmap_helper(SurfaceItem *item); - void updatePixmap_helper(SurfaceItem *item); - void referencePreviousPixmap_helper(SurfaceItem *item); void unreferencePreviousPixmap_helper(SurfaceItem *item); diff --git a/src/surfaceitem.h b/src/surfaceitem.h index adbdc07b4a..58df8136d3 100644 --- a/src/surfaceitem.h +++ b/src/surfaceitem.h @@ -31,6 +31,9 @@ public: void resetDamage(); QRegion damage() const; + void discardPixmap(); + void updatePixmap(); + SurfacePixmap *pixmap() const; SurfacePixmap *previousPixmap() const; @@ -43,9 +46,6 @@ protected: virtual SurfacePixmap *createPixmap() = 0; void preprocess() override; - void discardPixmap(); - void updatePixmap(); - QRegion m_damage; QScopedPointer m_pixmap; QScopedPointer m_previousPixmap; diff --git a/src/toplevel.cpp b/src/toplevel.cpp index 22460ce126..952363c0e1 100644 --- a/src/toplevel.cpp +++ b/src/toplevel.cpp @@ -282,12 +282,6 @@ void Toplevel::finishCompositing(ReleaseReason) } } -void Toplevel::discardWindowPixmap() -{ - if (effectWindow() != nullptr && effectWindow()->sceneWindow() != nullptr) - effectWindow()->sceneWindow()->discardPixmap(); -} - bool Toplevel::compositing() const { if (!Workspace::self()) { diff --git a/src/toplevel.h b/src/toplevel.h index 456a7d8a6a..e6e41aee08 100644 --- a/src/toplevel.h +++ b/src/toplevel.h @@ -669,7 +669,6 @@ protected: void detectShape(xcb_window_t id); virtual void propertyNotifyEvent(xcb_property_notify_event_t *e); virtual void clientMessageEvent(xcb_client_message_event_t *e); - void discardWindowPixmap(); Xcb::Property fetchWmClientLeader() const; void readWmClientLeader(Xcb::Property &p); void getWmClientLeader(); diff --git a/src/x11client.cpp b/src/x11client.cpp index 144564e0cc..c5443d9ffd 100644 --- a/src/x11client.cpp +++ b/src/x11client.cpp @@ -1500,6 +1500,7 @@ void X11Client::doSetShade(ShadeMode previousShadeMode) info->setState(isShown(false) ? NET::States() : NET::Hidden, NET::Hidden); updateVisibility(); updateAllowedActions(); + discardWindowPixmap(); } void X11Client::updateVisibility() @@ -4744,10 +4745,17 @@ void X11Client::damageNotifyEvent() } } +void X11Client::discardWindowPixmap() +{ + if (auto item = surfaceItem()) { + item->discardPixmap(); + } +} + void X11Client::updateWindowPixmap() { - if (effectWindow() && effectWindow()->sceneWindow()) { - effectWindow()->sceneWindow()->updatePixmap(); + if (auto item = surfaceItem()) { + item->updatePixmap(); } } diff --git a/src/x11client.h b/src/x11client.h index 42b8042c77..c0fd3bdbd2 100644 --- a/src/x11client.h +++ b/src/x11client.h @@ -411,6 +411,7 @@ private: void updateInputShape(); void updateServerGeometry(); + void discardWindowPixmap(); void updateWindowPixmap(); xcb_timestamp_t readUserTimeMapTimestamp(const KStartupInfoId* asn_id, const KStartupInfoData* asn_data,