Bug 504943

Summary: Focus does not switch context after switching activities
Product: [Plasma] kwin Reporter: Misha <merement>
Component: activitiesAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED WORKSFORME    
Severity: normal CC: kde
Priority: NOR    
Version First Reported In: 6.3.5   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Mouse cursor has a characteristic shape indicating that it is over a clickable link in a browser opened in another activity

Description Misha 2025-05-29 03:06:58 UTC
Created attachment 181841 [details]
Mouse cursor has a characteristic shape indicating that it is over a clickable link in a browser opened in another activity

SUMMARY
Switching activities using a shortcut (palsmashell's "Walk through activities") leaves the focus under the mouse cursor on the previous activity. 

The attached image illustrates how it may visually appear: the mouse cursor has a shape indicating that it is over a link in a browser opened in the second activity. Clicking the mouse sends the clicks to the second activity. Under some circumstances, after that, even keyboard events are sent to the second activity. For instance, one can select text in an editor opened in the second activity using the mouse and then replace that text by typing.

Having a browser (either Firefox or Chrome) open, even if it's may be the key part of the bug. 

STEPS TO REPRODUCE
On my computer, it is reliably reproduced by the following steps
1. On one activity, open an editor (say, Kate, but it doesn't matter) and type several lines of text
2. Switch to the second activity by a shortcut (in my case, it's Meta-A)
3. In the second activity, select the part of the screen covered by the Kate window in the first activity, and press a symbolic button (say, 'd')

OBSERVED RESULT
Switch back to the first activity and see the text in Kate replaced by 'd'.

EXPECTED RESULT
Nothing should happen with the text in a different activity.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Manjaro Linux x86_64
KDE Plasma Version: 6.3.5
KDE Frameworks Version: 6.14.0
Qt Version: 6.9.0
Graphics Platform: X11

ADDITIONAL INFORMATION

"Workaround": After switching the activities, press Alt-Tab to (visually) switch focus to the desired window.
Comment 1 David Edmundson 2025-05-29 06:50:41 UTC
Can you confirm if this is still an issue on wayland? I could not reproduce
Comment 2 Misha 2025-05-29 15:27:42 UTC
(In reply to David Edmundson from comment #1)
> Can you confirm if this is still an issue on wayland? I could not reproduce

Sorry for the delay, I could restart the computer only now.

There are no problems whatsoever on Wayland. The system behaves as expected.

On X11, after the restart, the problem reproduces right away on this computer. Tomorrow, I may gain access to another computer and will try it there. That computer also runs Manjaro KDE, but I don't use activities there and cannot say if the bug is there or not.

Meanwhile, in case I won't get to that computer tomorrow, if I can collect additional information, I'd be happy to cooperate.
Comment 3 Misha 2025-05-30 00:16:31 UTC
I found what triggers the unexpected behavior - it's a udev rule that modifies the behavior of a keyboard (not from the same vendor as the mouse).

DETAILS:
In "/etc/udev/hwdb.d", I have a rule (the only file in that directory) that swaps Home and Delete keys on a keyboard (Keychron K6). The content of the file is

evdev:input:b0005v05ACp024F*
 KEYBOARD_KEY_7004a=delete
 KEYBOARD_KEY_7004c=home

If this file is removed, the rules are updated, and (just in case) the computer is restarted, the bug disappears.

If the rule is reinstated, the bug appears even if no devices with the same vendor ID (0x05AC) are connected to the computer.

I don't have sufficient knowledge of Linux internals to understand how this works and why this doesn't affect Wayland, but this is what empirical observations are. So, I guess, after all, KDE has little to do with this.
Comment 4 Bug Janitor Service 2025-06-14 03:47:49 UTC
๐Ÿ›๐Ÿงน โš ๏ธ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 5 Misha 2025-06-14 05:07:45 UTC
This behavior is persistent. While I reported that it went away after removing the rule file in "/etc/udev/hwdb.d/", I was overly optimistic. Reproducing the behavior seems to become a bit more involved, but it's there. Unfortunately, the "involved" reproduction is a routine part of my workflow, so I eventually switched to Wayland on my main computer.

Today, I easily reproduced it on another computer (quite different hardware but the same software). That computer never had udev rules changed and a Keychron keyboard connected. It has the same installation of Manjaro since at least 2020. The reproduction was easy because I only repeated what I usually come to on my main computer: the first activity has Chrome on the first virtual desktop, Dolphin and Emacs opened on the second virtual desktop. On the second activity, Firefox opened on the second virtual desktop along with Dolphin and Emacs. After switching between the activities using the hot key a couple of times, I could click links on a webpage opened in Chrome in the first activity while being in the second activity.

If there's any specific data that I could collect to pinpoint the origin of this behavior, I'd be happy to cooperate.
Comment 6 Bug Janitor Service 2025-06-29 03:47:25 UTC
๐Ÿ›๐Ÿงน โš ๏ธ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 7 Bug Janitor Service 2025-07-14 03:47:32 UTC
๐Ÿ›๐Ÿงน This bug has been in NEEDSINFO status with no change for at least 30 days. Closing as RESOLVED WORKSFORME.