https://bugs.kde.org/show_bug.cgi?id=520317

--- Comment #13 from [email protected] ---
Disclosure: I used an AI assistant (Mistral Vibe) to help debug this — to
correlate
systemd journal logs with upstream source code and to help structure this
analysis.


ROOT CAUSE
----------

Repro requires the *display* (not the system) to sleep and wake on a single
external DisplayPort monitor. When the monitor deep-sleeps it drops the DP
hot-plug-detect line; on wake it re-asserts it. KWin treats this as the output
being removed/re-added:

- KWin removes the only output and creates an internal PlaceholderOutput
  (kwin/src/workspace.cpp:1454).
- Wayland clients then see zero real outputs; Qt's Wayland QPA synthesizes a
  nameless placeholder QScreen and logs There are no outputs - creating
  placeholder screen (qtbase qwaylanddisplay.cpp). That is exactly the
  "Peripheral disconnected/connected" sequence I see on wake since 6.6.90.

Journal evidence from today (2026-11-09, session locked 22:28:55, monitor off
22:29:55, wake + unlock at 22:43):

    nov. 09 22:43:11  ACPI group/action undefined: jack/videoout / VIDEOOUT
    nov. 09 22:43:12  org_kde_powerdevil: DDCA_EVENT_DISPLAY_DISCONNECTED,
card1-DP-3
    nov. 09 22:43:12  plasmashell: There are no outputs - creating placeholder
screen
    nov. 09 22:43:12  kscreenlocker_greet: There are no outputs - creating
placeholder screen
    nov. 09 22:43:13  org_kde_powerdevil: DDCA_EVENT_DISPLAY_CONNECTED,
card1-DP-3
    nov. 09 22:43:17  ACPI group/action undefined: button/kpenter / KPENTER  
(unlock)

The taskbar filter is TaskFilterProxyModel::acceptsRow() in
plasma-workspace/libtaskmanager/taskfilterproxymodel.cpp:425-444, enabled by
the
taskmanager applet via filterByCurrentVirtualDesktop:
Plasmoid.configuration.showOnlyCurrentDesktop
(plasma-desktop/applets/taskmanager/qml/main.qml:167). The per-screen
current-desktop check only rejects a window if its ScreenGeometry matches one
of
the *current* QScreens:

    if (!virtualDesktops.isEmpty() && screenGeometry.isValid()) {
        for (auto screen : qGuiApp->screens()) {
            if (screen->geometry() != screenGeometry) {
                continue;
            }
            if
(!virtualDesktops.contains(d->virtualDesktopInfo->currentDesktopByScreenName(screen->name())))
{
                return false;
            }
            break;
        }
    }   // no matching QScreen -> falls through -> row ACCEPTED

During the blackout the only QScreen is the placeholder (different geometry,
empty name), so no screen matches and every window passes the "current desktop
only" filter. Additionally, VirtualDesktopInfo::WaylandPrivate erases the
per-screen entry on screenRemoved (virtualdesktopinfo.cpp:322-324), and the
filter is only re-invalidated on dataChanged(ScreenGeometry) or
currentDesktopForScreenChanged (taskfilterproxymodel.cpp:88-92) — so the wrong
state persists after wake+unlock until the user switches desktops, which emits
currentDesktopChanged -> invalidateFilter().

This explains all reported conditions: Meta+L alone doesn't drop HPD, so no
bug;
with 2+ monitors a real QScreen always remains, so no bug; single DP monitor +
actual display sleep = bug; switching desktops temporarily fixes it.

PROPOSED FIX
------------

Make the per-screen desktop filter fail *closed*: when the window's screen
cannot
be matched to a current QScreen (placeholder during output hotplug), fall back
to
the global current desktop instead of accepting the row; and re-invalidate the
filter when screens are added/removed so the taskbar corrects itself as soon as
the
real output returns.

    --- a/libtaskmanager/taskfilterproxymodel.cpp
    +++ b/libtaskmanager/taskfilterproxymodel.cpp
    @@ (acceptsRow, per-screen virtual desktop filter)
                 if (!virtualDesktops.isEmpty() && screenGeometry.isValid()) {
    +                QVariant currentDesktop;
    +                bool screenMatched = false;
                     for (auto screen : qGuiApp->screens()) {
                         if (screen->geometry() != screenGeometry) {
                             continue;
                         }
    -                    if
(!virtualDesktops.contains(d->virtualDesktopInfo->currentDesktopByScreenName(screen->name())))
{
    -                        return false;
    -                    }
    +                    screenMatched = true;
    +                    currentDesktop =
d->virtualDesktopInfo->currentDesktopByScreenName(screen->name());
                         break;
                     }
    +                // If the window's screen cannot be matched to any current
QScreen
    +                // (e.g. the placeholder screen Qt creates when the last
real output
    +                // is removed while the display sleeps), fall back to the
global
    +                // current desktop instead of accepting the window.
    +                if (!screenMatched || currentDesktop.isNull()) {
    +                    currentDesktop =
d->virtualDesktopInfo->currentDesktop();
    +                }
    +                if (!virtualDesktops.contains(currentDesktop)) {
    +                    return false;
    +                }
                 }
    @@ (Private constructor, after the dataChanged connect)
    +    // Re-evaluate screen/desktop filtering when outputs come and go
    +    // (e.g. display sleeping and waking on a single-monitor setup).
    +    connect(qGuiApp, &QGuiApplication::screenAdded, this, [this]() {
    +        if (d->filterByScreen || d->filterByCurrentVirtualDesktop) {
    +            invalidateFilter();
    +        }
    +    });
    +    connect(qGuiApp, &QGuiApplication::screenRemoved, this, [this]() {
    +        if (d->filterByScreen || d->filterByCurrentVirtualDesktop) {
    +            invalidateFilter();
    +        }
    +    });

ROOT-CAUSE ALTERNATIVE (KWIN SIDE)
----------------------------------

Deeper fix: on DPMS-off/HPD-drop of the last output, keep the Output alive
(powered off) instead of tearing it down, so clients never see zero outputs and
Qt
never inserts the placeholder screen. This likely also fixes the
placeholder-screen
glitches tracked in bugs 522564 and 513003. Riskier change; the libtaskmanager
patch above is the targeted fix for this ticket.

ENVIRONMENT
-----------

- Arch Linux, Plasma 6.8.2 (plasmashell 6.8.2), kwin_wayland, Qt 6.x, kernel
7.2.14-zen
- Single external monitor on native DisplayPort (card1-DP-3, AMDGPU here;
originally
  reported on Intel UHD 630 — mechanism is GPU-independent, it's the monitor's
HPD)
- Reproduced again today: lock 22:28:55 -> display off 22:29:55 -> wake
22:43:11-13
  (disconnect/connect storm while locked) -> unlock 22:43:17

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to