diff --git a/src/scene.cpp b/src/scene.cpp index 7ca2a29562..3de35b3e20 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -138,6 +138,7 @@ QRect SceneDelegate::viewport() const Scene::Scene(QObject *parent) : QObject(parent) + , m_filter(this) { } @@ -611,10 +612,8 @@ void Scene::createStackingOrder() if (!win->readyForPainting()) { windows.removeAll(win); } - if (waylandServer() && waylandServer()->isScreenLocked()) { - if (!win->isLockScreen() && !win->isInputMethod()) { - windows.removeAll(win); - } + if (!m_filter.filterAcceptsWindow(win)) { + windows.removeAll(win); } } @@ -654,7 +653,7 @@ void Scene::finalPaintWindow(EffectWindowImpl *w, int mask, const QRegion ®io // will be eventually called from drawWindow() void Scene::finalDrawWindow(EffectWindowImpl *w, int mask, const QRegion ®ion, WindowPaintData &data) { - if (waylandServer() && waylandServer()->isScreenLocked() && !w->window()->isLockScreen() && !w->window()->isInputMethod()) { + if (!m_filter.filterAcceptsWindow(w->window())) { return; } w->sceneWindow()->performPaint(mask, region, data); @@ -871,4 +870,20 @@ Scene::EffectFrame::~EffectFrame() { } +//**************************************** +// ScreenLockerFilter +//**************************************** + +ScreenLockerFilter::ScreenLockerFilter(Scene *s) +{ + QObject::connect(waylandServer(), &WaylandServer::lockStateChanged, s, &Scene::addRepaintFull); +} + +ScreenLockerFilter::~ScreenLockerFilter() = default; + +bool ScreenLockerFilter::filterAcceptsWindow(KWin::Toplevel *w) const +{ + return !waylandServer()->isScreenLocked() || (w->isLockScreen() || w->isInputMethod()); +} + } // namespace diff --git a/src/scene.h b/src/scene.h index 3d9e288ff5..9c2df6c29c 100644 --- a/src/scene.h +++ b/src/scene.h @@ -15,6 +15,8 @@ #include "toplevel.h" #include "utils/common.h" +#include + #include #include @@ -44,6 +46,15 @@ class SurfacePixmapX11; class SurfaceTexture; class WindowItem; +class ScreenLockerFilter +{ +public: + ScreenLockerFilter(Scene *scene); + ~ScreenLockerFilter(); + + bool filterAcceptsWindow(KWin::Toplevel *w) const; +}; + class SceneDelegate : public RenderLayerDelegate { Q_OBJECT @@ -264,6 +275,7 @@ protected: // windows in their stacking order QVector stacking_order; + ScreenLockerFilter m_filter; private: std::chrono::milliseconds m_expectedPresentTimestamp = std::chrono::milliseconds::zero(); diff --git a/src/scenes/opengl/scene_opengl.cpp b/src/scenes/opengl/scene_opengl.cpp index 50d8de6fff..21000d63cb 100644 --- a/src/scenes/opengl/scene_opengl.cpp +++ b/src/scenes/opengl/scene_opengl.cpp @@ -313,7 +313,7 @@ Scene::Window *SceneOpenGL::createWindow(Toplevel *t) void SceneOpenGL::finalDrawWindow(EffectWindowImpl *w, int mask, const QRegion ®ion, WindowPaintData &data) { - if (waylandServer() && waylandServer()->isScreenLocked() && !w->window()->isLockScreen() && !w->window()->isInputMethod()) { + if (!m_filter.filterAcceptsWindow(w->window())) { return; } performPaintWindow(w, mask, region, data); diff --git a/src/wayland_server.cpp b/src/wayland_server.cpp index e9a6724513..9a84c56009 100644 --- a/src/wayland_server.cpp +++ b/src/wayland_server.cpp @@ -600,6 +600,7 @@ void WaylandServer::initScreenLocker() connect(seat, &KWaylandServer::SeatInterface::timestampChanged, screenLockerApp, &ScreenLocker::KSldApp::userActivity); } + Q_EMIT lockStateChanged(); }); connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::unlocked, this, [this, screenLockerApp]() { @@ -615,7 +616,7 @@ void WaylandServer::initScreenLocker() screenLockerApp, &ScreenLocker::KSldApp::userActivity); } ScreenLocker::KSldApp::self()->setWaylandFd(-1); - Compositor::self()->scene()->addRepaintFull(); + Q_EMIT lockStateChanged(); }); ScreenLocker::KSldApp::self()->initialize(); diff --git a/src/wayland_server.h b/src/wayland_server.h index a20ba65e27..fdccf3c297 100644 --- a/src/wayland_server.h +++ b/src/wayland_server.h @@ -239,6 +239,7 @@ Q_SIGNALS: void shellClientRemoved(KWin::AbstractClient *); void initialized(); void foreignTransientChanged(KWaylandServer::SurfaceInterface *child); + void lockStateChanged(); private: int createScreenLockerConnection();