https://bugs.kde.org/show_bug.cgi?id=508415

            Bug ID: 508415
           Summary: Kwin input events interference with IME switching
    Classification: Plasma
           Product: kwin
      Version First master
       Reported In:
          Platform: Arch Linux
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: input
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

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.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to