Bug 478192 - Sometimes widgets activated by a global shortcut stop receiving the shortcut until plasmashell is restarted
Summary: Sometimes widgets activated by a global shortcut stop receiving the shortcut ...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: general (show other bugs)
Version: 5.90.0
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2023-12-07 05:08 UTC by Adam Fontenot
Modified: 2023-12-24 12:01 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Fontenot 2023-12-07 05:08:16 UTC
SUMMARY
This is specifically about the "Search" widget. I have it configured (right click -> Configure Search) to be activated by a keyboard shortcut. This almost always works, but sometimes (I haven't found a pattern so far) it will stop receiving the shortcut. 

When this happens, changing the shortcut to a different shortcut doesn't solve the issue. Changing the shortcut works fine - but the new shortcut fails to activate the Search widget.

I assume this also applies to other widgets that can be activated by keyboard shortcuts. If someone can suggest something to test, I'm glad to add additional information.

STEPS TO REPRODUCE
1. Put the Search widget in your panel.
2. Set a keyboard shortcut to activate the widget (I used the "Menu" key, which I have Caps Lock bound to).
3. Use the shortcut frequently in your regular workflow. If / when it stops working, change the shortcut to something else and see if that helps (I used a Ctrl+letter that had no other mapping).

OBSERVED RESULT
At some point (?) the shortcut stops working. When this happens, changing the shortcut does not allow activating the widget via keyboard. The widget remains functional, responds to cursor clicks, and accepts text input when clicked.

As expected, having the "Menu" key bound to a global shortcut prevents it from activating context menus in running programs. (This is desired behavior in my use case.) When the issue occurs, KDE continues to intercept the Menu key and it does not activate context menus.

Adding a second Search widget does not solve the problem.

`pkill -9 plasmashell` does not immediately fix the problem (plasmashell is automatically restarted), but upon opening the Search widget settings, no keyboard shortcut is set. Setting the keyboard shortcut to the Menu key fixes the problem.

EXPECTED RESULT
Plasma never stops responding to the selected keyboard shortcut.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.90.0
KDE Frameworks Version: 5.246.0
Qt Version: 6.6.1
Kernel Version: 6.6.4-arch1-1 (64-bit)
Graphics Platform: Wayland
Comment 1 Nate Graham 2023-12-07 20:36:50 UTC
FWIW I've got a Notes widget in my panel that I activate with Meta+N and I've never had this happen in Plasma 6.

When this happens, does restarting plasmashell help? How about restarting KWin?
Comment 2 Adam Fontenot 2023-12-07 21:34:43 UTC
> does restarting plasmashell help

Yes, this is buried in my "observed result" section:

> `pkill -9 plasmashell` does not immediately fix the problem (plasmashell is
> automatically restarted), but upon opening the Search widget settings, no
> keyboard shortcut is set. Setting the keyboard shortcut to the Menu key fixes
> the problem.
Comment 3 Nate Graham 2023-12-11 21:21:08 UTC
Thanks, sorry I missed that.
Comment 4 Akseli Lahtinen 2023-12-12 09:06:18 UTC
I fixed very similar bug recently for Plasma 6: https://invent.kde.org/plasma/libplasma/-/merge_requests/987

Have you encountered this again? Currently trying to reproduce the issue.
Comment 5 Akseli Lahtinen 2023-12-12 09:21:25 UTC
Does this only happen after editing a panel? Seems for me, the panel focus stops working after toggling the edit mode.
Comment 6 Adam Fontenot 2023-12-14 22:45:38 UTC
I think I figured out how to reproduce this.

1. Set up your computer to automatically switch to an external monitor when it is connected. (Single screen mode - the existing screen should turn off automatically.)
2. Set up a global shortcut on a panel widget and check that it is working on your main screen.
3. Plug in the other screen.
4. Try the shortcut again.

This breaks the global shortcut for me. Restarting plasmashell using any method (while leaving the screen plugged in) fixes it.

Once it has been fixed, *unplugging* the screen, which moves the panel back to the first screen, breaks it on that screen. Plugging the external screen back in (without restarting plasmashell) gets it to work on the external screen without further intervention.

So the global shortcut only works for me on the screen that my panel starts on.
Comment 7 Adam Fontenot 2023-12-14 23:44:14 UTC
Two quick clarifications:

> Does this only happen after editing a panel?

No, it happens regardless of whether I have edited a panel since the last reboot.

> does restarting plasmashell help

I initially said the answer to this is "no, but it allows you to set the shortcut again". I actually think it does, now. It appears that if you immediately restart plasmashell when you notice the problem, it fixes it. If instead you start tinkering with the shortcut settings on the widget, the "new" shortcut you set will fail to take effect, and so when you restart plasmashell *after* that the shortcut disappears. (It's also possible I screwed up the initial test and removed the shortcut before restarting plasmashell.)
Comment 8 Akseli Lahtinen 2023-12-15 12:34:23 UTC
Managed to reproduce this, however unsure if this is the only cause.

1. Let your PC go to screen-blanking mode (screen turns black)
2. Wait a few seconds
3. Shake mouse to wake up screen
4. Shortcuts do not work anymore, until focused again by clicking with mouse

To me seems the problem is with the screen going black and something pausing during it.
Comment 9 Akseli Lahtinen 2023-12-15 12:52:12 UTC
Okay I got the bug now, but I have no idea why it happens.

If I press Meta+S to toggle the search widget, instead of search opening, my cursor turns into the resize horizontally icon. Super weird, will try to investigate. But it started only after the screen blanking: I have been trying to repro this bug the whole week and only after screen blanking it happens.
Comment 10 Akseli Lahtinen 2023-12-15 12:53:48 UTC
(In reply to Akseli Lahtinen from comment #9)
> Okay I got the bug now, but I have no idea why it happens.
> 
> If I press Meta+S to toggle the search widget, instead of search opening, my
> cursor turns into the resize horizontally icon. Super weird, will try to
> investigate. But it started only after the screen blanking: I have been
> trying to repro this bug the whole week and only after screen blanking it
> happens.

To add, restarting plasmashell fixed this.
Comment 11 Akseli Lahtinen 2023-12-19 08:55:26 UTC
Seems the shortcut can't connect to the assigned window ID:

Dec 19 10:50:34 fedora-desktop kwin_wayland[111261]: kwin_core: Could not find window with uuid "{210136f9-bdb6-439f-9f02-f031900489b0}
Comment 12 Akseli Lahtinen 2023-12-19 08:58:51 UTC
To summarise:

1. set shortcut to any plasmawidget like weather, calendar, etc.. any widget inside panel
2. let powersaving turn screen 
3. wait couple minutes
4. shake mouse but dont click anything
5. try to open the widget with the shortcut
6. nothing happens
7. journalctl screams something like kwin_core: Could not find window with uuid "{210136f9-bdb6-439f-9f02-f031900489b0}

Seems when screen is turned off, the window uuid is forgotten?


seems when screen is turned off, the window uuid's are forgotten?
Comment 13 Bug Janitor Service 2023-12-19 11:31:51 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/libplasma/-/merge_requests/1019
Comment 14 Akseli Lahtinen 2023-12-19 12:05:43 UTC
Git commit 27b4578ede769980145774e2f03d4ba970dc1c73 by Akseli Lahtinen.
Committed on 19/12/2023 at 13:05.
Pushed by akselmo into branch 'master'.

AppletQuickItem: Return in itemchange if already initialized

M  +3    -2    src/plasmaquick/appletquickitem.cpp

https://invent.kde.org/plasma/libplasma/-/commit/27b4578ede769980145774e2f03d4ba970dc1c73
Comment 15 Adam Fontenot 2023-12-20 01:52:23 UTC
Confirming this fixes the issue as I experienced it with monitor switching as well. (I was never able to reproduce the problem when power saving turned off the screen.)
Comment 16 d_avery 2023-12-24 12:01:43 UTC
Hello! Does this fix 418288 (403636?)? I've been having issues with media keys stopping working seemingly randomly (5.27.10 Wayland at time of writing). Or is the Media Controller handled differently? Thank you.