Bug 505343

Summary: Focus does not match visual when switching activity
Product: [Plasma] kwin Reporter: tech
Component: activitiesAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal CC: ivan.cukic, jkanev, nate, wittemar
Priority: NOR    
Version First Reported In: 6.3.5   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description tech 2025-06-08 12:42:57 UTC
***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports

Please remove this comment after reading and before submitting - thanks!
***

SUMMARY
Windows are messed up after switching activities for some time. 
When this happens (both in Wayland and X11) I see the correct window on the correct place in the selected activity but input will go to the activity I switched from and where I last had correct input. 

STEPS TO REPRODUCE
At the moment it always happens after I have been logged in for a while. I switch activities a lot. I also use a lot of different instances of both Firefox and Google Chrome (both started so that different instances are using different profiles). 

OBSERVED RESULT
For a start I have e.g. google calendar in a firefox in focus in an activity and it works properly when I click in the browser and I can create meetings. I have Google Calendar in a week view. 

I then switch activity where I have QtCreator running. QtCreator will appear. When I click in an open source file input still goes to google calendar and I can both create new and mess upp existing meetings. 

I have also manage to click in a chrome browser and get the File meny from the application I last used in the recent activity. 

This happens occationally, not all the time. 

In X11 it is possible to get focus right bu selecting the application in the panel. I have to check if this work in 
Wayland as well. 

EXPECTED RESULT
Input goes in the window I see on the screen and where I seemingly click. 

SOFTWARE/OS VERSIONS
Operating System: Gentoo Linux 2.17
KDE Plasma Version: 6.3.5
KDE Frameworks Version: 6.14.0
Qt Version: 6.8.3
Kernel Version: 6.14.6-gentoo-dist (64-bit)
Graphics Platform: X11
Processors: 32 × AMD Ryzen 9 9950X 16-Core Processor
Memory: 123.4 Gibyte of RAM
Graphics Processor 1: AMD Radeon Pro W7600
Graphics Processor 2: AMD Radeon Graphics
Manufacturer: ASRock
Product Name: X870 Pro RS

ADDITIONAL INFORMATION
Comment 1 Nate Graham 2025-06-09 20:25:00 UTC
Does it happen on Wayland too, or only X11?
Comment 2 tech 2025-06-10 12:12:43 UTC
Hi, 
This happens on both X11 and Wayland but I think the exact behavior differs slight. 

Testing in OpenSuse to see if it happens here as well but it works better here than on gentoo. So far only happen one time during a teams meeting when I shared screen using Web-Teams in Google Chrome. Since I stopped sharing things are back to normal. 

I do a lot of screen sharing (have a lot of teams-meetings) and if that is a trigger things will eventually go down the drain.

I run teams  for different several different tenants, each in a separate google chrome instance with an own profile. I can have a meeting in one tenant in one instance and start a meeting in another short after.

Can it be that it has to do with the new KDE Share Screen thingie? I am not 100% sure but I think the problems started with the same release as when I had to share screen a second time from a KDE realted dialog. (There are two dialogs, first one from web-teams inside the chrome window and then a second one in a separate floating window).
Comment 3 tech 2025-06-10 17:14:42 UTC
Forgott the systems information about openSuse:

Operating System: openSUSE Tumbleweed-Slowroll 20250501
KDE Plasma Version: 6.3.5
KDE Frameworks Version: 6.13.0
Qt Version: 6.9.0
Kernel Version: 6.14.6-1.0.4.sr20250501-default (64-bit)
Graphics Platform: Wayland
Processors: 32 × AMD Ryzen 9 9950X 16-Core Processor
Memory: 64.4 Gibyte of RAM
Graphics Processor 1: AMD Radeon Pro W7600
Graphics Processor 2: AMD Radeon Graphics
Manufacturer: ASRock
Product Name: X870 Pro RS
Comment 4 Nate Graham 2025-06-10 17:18:48 UTC
Please stop changing the product back to plasmashell.
Comment 5 Marcel 2025-06-15 20:20:21 UTC
I have the same problem. Most of the times this happens when switching activities using Meta+Tab. If I then click on any window the window in the old activity on that position gets focus again and the activity switches back. Clicking on the window title to give the visible window focus is working as a workaround.
Comment 6 tech 2025-06-18 11:08:25 UTC
Sorry for the product changing, it was unintentional. 

It is a problem both on openSuse tumbleweed and Gentoo. Not updated to latest kde baselines though so still on plasma 6.3.5. 

I think it affects programs that is not KDE programs most or even only. It affects Google Chrome, my Eclipse based modelling tool and Firefox. 
I never seems to affect my own developed Qt based software or KDE applications I use a lot (Dolphin or Kate).

I have an own qt based desktop wiki Neville that I use a lot and in many instances al over the place. I can't recall a single time when there was a problem with that one and it is still a Qt5 application.
Comment 7 Marcel 2025-06-19 07:29:38 UTC
This is not fixed in Plasma 6.4.0
Comment 8 Jacob Kanev 2025-07-07 19:58:35 UTC
I can confirm. What I observe on Debian (see also bug report there, https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1108914):

• When working with a program window (mail client, browser, editor, anything), and then switching activities, the focus stays on that same window.
→ Example: I work with my email client. I switch activities using the activity switcher in the task bar. I now see the web browser. I click on the web browser window. The windows does not react. A menu pops up asking whether I want to move that email.
→ Other example: I work in a text editor. I mark some text. I switch activities and now see my web browser. I click the web browser window, I want to go back one page and hit the delete key. Nothing happens. Going back to the previous activity, I find I've just deleted the marked text in the text editor.

• What I see: When switching to a different activity using the activity switcher, the window that had the focus before switching keeps the focus. The windows that is visible under the mouse does not receive mouse nor keyboard input.

• Notes:
→ To activate the current window, after switching activities, I have to press the respective button in the task list.
→ Other flavours of the "focus follows mouse" setting in the systemsettings have the same effect.
→ When staying in the same activity, the focus works as expected.
→ This happens reproducibly, but it seems to be in groups, supporting the KDE-apps assumption by Marcel. (Just tried: I have activities A, B, C, dolphin on A, firefox on B, pycharm on C. Type in firefox on B. Switch to C - pycharm works. Switch to A - dolphin doesn't react. Activate dolphin on A, both firefox on B and pycharm on C don't work (clicking pycharm opens a file from dolphin). Activate pycharm on C - firefox on B works again, dolphin on A does not.)
Comment 9 Jacob Kanev 2025-07-09 14:56:57 UTC
I think the Importance of this should go up. Clicking or typing into a window, and then things are done in another window (which is not even visible), can lead to data loss. The user will only discover the problem a lot later, when they switch back to the original activity. I've actually deleted two emails that way, by clicking into a different window and hitting delete there.
Comment 10 Nate Graham 2025-07-17 14:27:05 UTC

*** This bug has been marked as a duplicate of bug 501393 ***