Bug 508415 - IME switching should be possible without an active input method context
Summary: IME switching should be possible without an active input method context
Status: CONFIRMED
Alias: None
Product: kwin
Classification: Plasma
Component: input (other bugs)
Version First Reported In: master
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-18 09:58 UTC by Yatao Li
Modified: 2025-08-18 14:45 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yatao Li 2025-08-18 09:58:29 UTC
Issue moved from: https://invent.kde.org/plasma/plasma-desktop/-/issues/151

## Problem description

So when I want to launch an app or search for a file, I usually hit meta to kick off the app launcher, and then type my search conditions. This works well for English searches, but not quite so for duo-lingual setups, where one typically binds input method switching / keyboard mapping switching to `meta+space` (modern windows), `ctrl+space` (legacy windows) or `alt+space` (fruit computer) -- instead of switching the IME, the space key is intercepted by the favourates entry and will trigger an application launch instead.


## Repro

Say I want to search for `测试文档.docx`.
Hit meta to reveal the launcher:
![image](https://invent.kde.org/-/project/2802/uploads/8fff47d8e68d53416286516737b35e90/image.png)

Notice that I'm on English keyboard, and I want to switch to Chinese:
![image](https://invent.kde.org/-/project/2802/uploads/cac4e4020d3213cd2ee9b56f59c924f0/image.png){width=279 height=165}

So I hit `meta+space`, but instead of switching the IME, `firefox` is launched.

## Workaround

`KickoffGridDelegate` is the clickable item that treats space as button press and intercepted the event. 
So I directly patched the system file (ArchLinux):

```patch
--- a/KickoffGridDelegate.qml
+++ b/KickoffGridDelegate.qml
@@ -79,4 +79,11 @@ AbstractKickoffItemDelegate {
             color: root.iconAndLabelsShouldlookSelected ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
         }
     }
+
+    Keys.onPressed: event => {
+      if (event.key === Qt.Key_Space) {
+        event.accepted = true;
+        kickoff.searchField.forceActiveFocus(Qt.ShortcutFocusReason);
+      }
+    }
 }
```

```bash
#!/bin/bash

sudo patch /usr/share/plasma/plasmoids/org.kde.plasma.kickoff/contents/ui/KickoffListDelegate.qml < ./kickoff-redirect-spacekey-to-search.patch
sudo patch /usr/share/plasma/plasmoids/org.kde.plasma.kickoff/contents/ui/KickoffGridDelegate.qml < ./kickoff-redirect-spacekey-to-search.patch
```
(Note, the list delegates also intercepts space and prevents IME switching, but since it's a category menu, it doesn't launch anything)

However this breaks existing functionality of space activation, so I can't open a PR with this solution.

Ideally, the launcher (or anything that redirects input to a text input) should be aware of IME keyboard shortcut (fcitx5, ibus etc.), prevent default action (space, enter, etc.) and pass the signal to the IME switcher.
Comment 1 Zamundaaa 2025-08-18 14:45:25 UTC
> Ideally, the launcher (or anything that redirects input to a text input) should be aware of IME keyboard shortcut (fcitx5, ibus etc.), prevent default action (space, enter, etc.) and pass the signal to the IME switcher.
There isn't really a IME switcher or IME keyboard shortcut, the input method just grabs all keys and does *something* with them under the hood - one of them being that internal shortcut.
Kickoff doesn't focus the search field by default, so there's no input method active, so it can't grab anything. If you first click on the search field, it works.

The proper fix would imo be for the keyboard layout shortcut to be handled by KWin, as a normal global shortcut.