Bug 442044 - KWin does not respect the NET_WM_WINDOW_TYPE for sub-windows.
Summary: KWin does not respect the NET_WM_WINDOW_TYPE for sub-windows.
Status: CONFIRMED
Alias: None
Product: kwin
Classification: Plasma
Component: core (show other bugs)
Version: 5.22.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-05 17:03 UTC by Nils Fenner
Modified: 2021-09-23 12:26 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nils Fenner 2021-09-05 17:03:51 UTC
When "show desktop" action is triggered (e.g. by Meta+D shortcut) pcmanfm-qt stays visible in LXQt session.

STEPS TO REPRODUCE
1. Start LXQt session (implies: pcmanfm-qt --desktop)
2. Start pcmanfm-qt
3. Call "show desktop" action (e.g. Windows+D)

OBSERVED RESULT
pcmanfm-qt (file manager) stays visible on screen

EXPECTED RESULT
pcmanfm-qt (file manager) is hidden like a normal application

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 5.22.0
(available in About System)
KDE Plasma Version: not relevant
KDE Frameworks Version: not relevant
Qt Version: 5.15.2
(LXQt Version: 0.17)

ADDITIONAL INFORMATION

When LXQt session starts the first pcmanfm-qt instance implies the flag __NET_WM_WINDOW_TYPE_DESKTOP (aka Qt::WA_X11NetWmWindowTypeDesktop). KWin correctly detects it as a desktop window and does not hide it when "show desktop" action is triggered.

However pcmanfm-qt creates subsequent instances through a short-lived process resulting in a child window. KWin now takes the window flags from the parent (desktop window) and the (child) window always stays on screen.

For reference see LXQt bug #1411 (https://github.com/lxqt/pcmanfm-qt/issues/1411)
Comment 1 David Edmundson 2021-09-05 22:58:22 UTC
sub-window or child with a transient parent?
Comment 2 Nils Fenner 2021-09-06 10:07:42 UTC
The file manager Window has to be parented, because pcmanfm-qt runs as a single process.

FYI:
When pcmanfm-qt is used as a file manager, it just fires a dbus call and quits afterwards (explains why the process is short-lived).

That means:
When pcmanfm-qt receives the dbus call (I will send it for debugging) it creates a QMainWindow as child of the QApplication instance. Otherwise the LXQt session would create a mem-leak on quit (and likely also segfault).

(LXQt can probably workaround that by using a smart-pointer instead of parenting the window.)
Comment 3 Nils Fenner 2021-09-07 14:13:53 UTC
Actually I was wrong with the assumption of the parented window. The pcmanfm-qt MainWindow is a QMainWindow and unparented!

Presumingly KWin makes the false assumption here that an application can only have one top-level window (parent == nullptr)!

This is independent of window attributes and definitely a KWin bug. LXQt cannot workaround that!
Comment 4 Nils Fenner 2021-09-08 07:23:44 UTC
Here's a test application that cleanly reproduces that KWin behaviour:
https://gitlab.com/antis81/kwindesktopwindow
Comment 5 Nils Fenner 2021-09-13 09:57:25 UTC
Actually this is rather simple to solve by enhancing the transient strategy. Would you accept a "collaboration" by LXQt on that issue?
Comment 6 Vlad Zahorodnii 2021-09-14 08:01:49 UTC
FWIW, I cannot reproduce the issue on wayland with the demo running as an xwayland client.

(In reply to Nils Fenner from comment #5)
> Actually this is rather simple to solve by enhancing the transient strategy.
> Would you accept a "collaboration" by LXQt on that issue?
Sure, if it's a kwin bug, we would be happy to merge the fix.
Comment 7 Nils Fenner 2021-09-15 15:20:56 UTC
Thanks for the feedbaack Vlad! We will discuss it and propose a fix.
Comment 8 Vlad Zahorodnii 2021-09-15 16:42:56 UTC
Feel free to ping me in #kde-kwin on OFTC. I'm zzag.
Comment 9 Nils Fenner 2021-09-16 13:54:50 UTC
@Vlad From our IRC discussion:

All comes down to `BaseClient::bolongsToSameApplication()` (X11 client does not query this!). By changing the code in https://invent.kde.org/plasma/kwin/-/blob/master/src/layers.cpp#L736 it should work:

```c++
bool X11Client::belongsToDesktop() const
{
    const auto clients = group()->members();

    return std::any_of(clients.constBegin(), clients.constEnd(),
        [this](const AbstractClient *client) {
            if (belongsToSameApplication(client, SameApplicationChecks())) {
                return client->isDesktop();
            }
            return false;
        }
    );
}
```

Since my login doesn't work currently can you do that?
Comment 10 Nils Fenner 2021-09-18 08:38:51 UTC
@Vlad Setting the window modality in the demo application has no effect on both (desktop and/or normal) windows. And it makes sense! Had a look at that deprecated Qt::WA_GroupLeader flag. If you search for "groupLeader" in kwin gitlab you will find the code is disabled.

Talking KWin X11Client here:
In addition we have "lxqt-panel" (separate process). Noteworthy that it doesn't set  "Qt::WA_X11NetWmWindowTypeDesktop" flag and instead "Qt::WA_X11NetWmWindowTypeDock".

What we have:
1. pcmanfm -> the only place where the "desktop" flag is set (https://github.com/lxqt/pcmanfm-qt/blob/aa2dc974840521afcd65a2e160641c2eef99ca16/pcmanfm/desktopwindow.cpp#L89).
2. lxqt-panel -> set the "dock" flag (https://github.com/lxqt/lxqt-panel/blob/7c0478ef9c7fc8998f7a7e0c844a8921e038d04d/panel/lxqtpanel.cpp#L167)

KWin filters all "clients" (regardless of the process!) and determines which "belong to the desktop". With wayland it seems to be handled well now by that "KeepAbove" + "belongsToSameApplication" magic.
Comment 11 Nils Fenner 2021-09-18 10:22:48 UTC
Actually checking on the "dock" flag when cycling in "X11Client::belongsToDesktop" should work in both Plasma and LXQt (KDE independent) shouldn't it? (Does the Plasma panel set the "dock" attribute? If not, has it another attribute suitable?).