From 05de198c41ede8148623c87d49fd7c7f91479dc3 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 21 Feb 2022 12:14:31 +0200 Subject: [PATCH] scene: Check SurfacePixmap's alpha channel to determine if surface is translucent If the main surface is translucent (e.g. it contains only the drop shadow) but its subsurface is opaque, the "window->isOpaque()" check will produce a false positive. --- src/scene.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/scene.cpp b/src/scene.cpp index 4fbefb47f0..007d7c8aa1 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -215,14 +215,17 @@ static SurfaceItem *findTopMostSurface(SurfaceItem *item) SurfaceItem *Scene::scanoutCandidate() const { + if (!waylandServer()) { + return nullptr; + } SurfaceItem *candidate = nullptr; if (!static_cast(effects)->blocksDirectScanout()) { for (int i = stacking_order.count() - 1; i >=0; i--) { Window *window = stacking_order[i]; Toplevel *toplevel = window->window(); - if (painted_screen && toplevel->isOnOutput(painted_screen) && window->isVisible() && toplevel->opacity() > 0) { + if (toplevel->isOnOutput(painted_screen) && window->isVisible() && toplevel->opacity() > 0) { AbstractClient *c = dynamic_cast(toplevel); - if (!c || !c->isFullScreen()) { + if (!c || !c->isFullScreen() || c->opacity() != 1.0) { break; } if (!window->surfaceItem()) { @@ -239,7 +242,7 @@ SurfaceItem *Scene::scanoutCandidate() const break; } // and it has to be completely opaque - if (!window->isOpaque() && !topMost->opaque().contains(QRect(0, 0, window->width(), window->height()))) { + if (pixmap->hasAlphaChannel() && !topMost->opaque().contains(QRect(0, 0, window->width(), window->height()))) { break; } candidate = topMost;