Bug 439027 - Qt::Tool windows don't regain focus after pop-ups close on X11
Summary: Qt::Tool windows don't regain focus after pop-ups close on X11
Status: RESOLVED UNMAINTAINED
Alias: None
Product: kwin
Classification: Plasma
Component: core (show other bugs)
Version: 5.22.1
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 441056 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-06-22 12:11 UTC by Frederick Zhang
Modified: 2023-09-06 10:38 UTC (History)
4 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 Frederick Zhang 2021-06-22 12:11:22 UTC
SUMMARY
Qt::Tool windows don't regain focus after pop-ups close on X11.

STEPS TO REPRODUCE
This issue was found when testing [1]. It doesn't impact Wayland.

1. Compile and run [2] (one-liner change based on Yakuake v21.04.2)
2. Execute: printf 'GETPIN\n' | pinentry-qt
3. Enter something random

OBSERVED RESULT
After pinentry closes, the last regular window gains focus instead
of Yakuake.

EXPECTED RESULT
Yakuake regains focus.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.22.1
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.2
Kernel Version: 5.12.12-zen1-1-zen (64-bit)
Graphics Platform: X11

[1] https://invent.kde.org/utilities/yakuake/-/merge_requests/42#note_257687
[2] https://invent.kde.org/frederickzhang/yakuake/commit/b950ee2c6321ef9d9c1259b9bec6cb9e57112c88
Comment 1 tamim 2021-08-16 12:13:06 UTC
Copy of my comment here https://invent.kde.org/utilities/yakuake/-/merge_requests/42#note_288516


This happens because the `Qt::Tool` flag sets the `Qt::WA_X11NetWmWindowTypeUtility` attribute. Making it an utility window which messes with the focus handling.

I didn't test this,yet. But clearing the attribute by something like  `setAttribute(Qt::WA_X11NetWmWindowTypeUtility, false);` should fix this, I think.

Simply forcing the window type to "normal window" with a window rule fixes the issue
Comment 2 Ricardo J. Barberis 2021-08-21 17:54:23 UTC
Could this also make yakuake not appear in the task switcher?

See https://bugs.kde.org/show_bug.cgi?id=441056
Comment 3 Ricardo J. Barberis 2021-08-21 18:07:41 UTC
Yep, setting the window type to "normal window" made yakuake show up again in the task switcher.
Comment 4 Ricardo J. Barberis 2021-08-21 18:09:15 UTC
*** Bug 441056 has been marked as a duplicate of this bug. ***
Comment 5 David Edmundson 2023-09-06 10:38:29 UTC
This bug was reported against an outdated version of KWin. We have made many changes since the. 
If the issue persists in newer versions can you reopen the bug report updating the version number.