Bug 486461 - When a dialog is the active window, closing it doesn't always focus and raise its parent window
Summary: When a dialog is the active window, closing it doesn't always focus and raise...
Status: CONFIRMED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 6.0.3
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 470631 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-05-02 15:15 UTC by Tomas Mecir
Modified: 2024-07-22 21:49 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
modal dialog from Dolphin (11.96 KB, image/png)
2024-07-13 14:59 UTC, Patrick Silva
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Mecir 2024-05-02 15:15:59 UTC
SUMMARY
Kwin-wayland is treating each window as separate when it comes to focus switching, instead of treating each application as a whole. This may be intentional, in which case a config option would be nice. It's different than the X11 behavior, however.

STEPS TO REPRODUCE
1. Open two apps, e.g. kate and dolphin
2. Open a dialog in dolphin - Configure for example
3. Click on kate to focus that window
4. Click back on dolphin's Configure window to focus it
5. Close the Configure window

OBSERVED RESULT
Window focus goes back to kate

EXPECTED RESULT
Focus goes to dolphin's main window

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 6.0.3
KDE Plasma Version: 
KDE Frameworks Version: 6.0.0
Qt Version: 6.7.0
Comment 1 Nate Graham 2024-05-03 19:38:33 UTC
Can confirm, and I don't think this is intentional. It's quite strange for the Kate window to have focus despite not being the top-most window when using the default focus policy. Typically this is something you have to use a non-default focus policy to achieve.
Comment 2 Patrick Silva 2024-07-13 14:59:28 UTC
Created attachment 171636 [details]
modal dialog from Dolphin

Yesterday I noticed this bug on my system while trying to copy data from some corrupted DVDs with Dolphin and browsing internet with Vivaldi browser running natively on Wayland. It makes focusing a previously used window by pressing alt+tab or clicking on its entry in the task manager to fail.

1. copy data with Dolphin
2. use Vivaldi while Dolphin copies data

When a failure with data copy occurs, a modal dialog from Dolphin (please see the screenshot attached to this comment) steals focus. After clicking on a button from the modal dialog, Dolphin window is appearing in foreground, but it is not focused. Then If I try to focus Vivaldi by pressing alt+tab, Dolphin is selected in the alt+tab menu instead of Vivaldi. If I try to selected Vivaldi by clicking on its entry in the task manager once instead of by pressing alt+tab, nothing happens. If I click on the entry of Vivaldi in the task manager again, it is focused as expected.

Operating System: Arch Linux 
KDE Plasma Version: 6.1.2
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.2
Kernel Version: 6.9.9-arch1-1 (64-bit)
Graphics Platform: Wayland
Comment 3 username 2024-07-22 01:34:59 UTC
I have the same issue, but I experience it in both Wayland and X11. Not sure if I should create separate report.

***
After closing active window, wrong window focused. Also you can experience same issue after close plasma popup or when switching screens by hotkey.
***

STEPS TO REPRODUCE
1. Open some windows, for exampe Dolphin, Kate and System Setting
2. Switch to Dolphin, then switch to Kate
3. Close Kate
4. System Settings window will be focused instead of Dolphin
4. If you not observe issue, then open more windows and try to focus/close windows again in random order

Also you can reproduce it this way:

1. Enable checkbox "Separate screen focus" in "Windows Behavior" setting
2. Open some windows on different screens
3. Press hotkey for "Switch to Next Screen" or "Switch to Screen #"
4. Wrong window will be focused
5. If you not observe issue, then focus some other window and try to switch screens again

OBSERVED RESULT
Wrong window focused

EXPECTED RESULT
Topmost window focused

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 6.1.3
KDE Frameworks Version: 6.4.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION
I use default "Click to focus" window activation policy if that matter
Comment 4 username 2024-07-22 10:46:55 UTC
I noticed a clear pattern that the focus always goes to the "last created window" instead of the "topmost window". This happens 100% of the time
Comment 5 Nate Graham 2024-07-22 21:49:36 UTC
*** Bug 470631 has been marked as a duplicate of this bug. ***