-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore Super and other modifier keys except for Alt #1059
Conversation
When using ibus-mozc with Japanese input mode enabled and set to full-width hiragana input mode, there is an issue where pressing Super+space inserts a full-width space instead of switching the input source. This PR resolves this issue. I tested it on Manjaro Linux(GNOME/Wayland) and confirmed that it works well. |
Hi kzys, Thank you for your PR with tests! Overall, it looks good to me. Thank you, |
src/unix/ibus/key_event_handler.cc
Outdated
@@ -38,6 +38,10 @@ namespace mozc { | |||
namespace ibus { | |||
|
|||
namespace { | |||
|
|||
// Mod1 is Alt, which is used by Mozc. | |||
const uint kExtraModMask = IBUS_MOD2_MASK | IBUS_MOD3_MASK | IBUS_MOD4_MASK | IBUS_MOD5_MASK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use constexper instead of const, and move this into the function.
Also please wrap the line within 80 chars.
// Mod1 is Alt, which is used by Mozc.
constexpr uint kExtraModMask =
IBUS_MOD2_MASK | IBUS_MOD3_MASK | IBUS_MOD4_MASK | IBUS_MOD5_MASK;
if (modifiers & kExtraModMask) {
return false;
}
src/unix/ibus/key_event_handler.cc
Outdated
@@ -62,6 +66,14 @@ bool KeyEventHandler::GetKeyEvent(uint keyval, uint keycode, uint modifiers, | |||
DCHECK(key); | |||
key->Clear(); | |||
|
|||
// If the key is pressed with these extra modifiers that Mozc doesn't know, | |||
// don't pass to the translator. | |||
// This is needed to handle Super-Space, IBus's default for switching input methods. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap the line within 80 chars.
// If the key is pressed with these extra modifiers that Mozc doesn't know,
// don't pass to the translator. This is needed to handle Super-Space, IBus's
// default for switching input methods.
// https://github.com/google/mozc/issues/853
Thanks! Addressed in the last revision. |
src/unix/ibus/key_event_handler.cc
Outdated
@@ -38,6 +38,7 @@ namespace mozc { | |||
namespace ibus { | |||
|
|||
namespace { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
I continued troubleshooting. For your reference.
|
Thanks for testing. Let me check. I don't have a Japanese keyboard nearby though. I don't know how these Japanese-specific keys get Mod2. Is it coming from XKB somehow? |
@phoepsilonix Can you check
|
Hi. lock Eisu_toggle (0x42) xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Eisu_toggle (0x42)
control Control_L (0x25), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Alt_L (0xcc), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3 ISO_Level5_Shift (0xcb)
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c) |
It seems that the on/off state of Num Lock is the key point of the issue. I use Num_Lock enabled at startup. I always keep Num_Lock on because I have a numeric keypad. Some keyboards don't have a numeric keypad, and Num_Lock might affect the main keyboard layout. I was wondering if this could be the cause of the issue. So I tested what happens when Num_Lock is turned off.
In other words, the on/off state of Num_Lock is affecting the behavior of the full-width/half-width key and the hiragana key. This issue does not occur with ibus-mozc without adding IBUS_MOD2_MASK to kExtraModMask. |
@phoepsilonix Thanks! That makes more sense. Updated the mask. |
src/unix/ibus/key_event_handler.cc
Outdated
constexpr uint kExtraModMask = | ||
IBUS_MOD3_MASK | IBUS_MOD4_MASK | IBUS_MOD5_MASK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line 72 should have 4 spaces for the indentation.
constexpr uint kExtraModMask =
IBUS_MOD3_MASK | IBUS_MOD4_MASK | IBUS_MOD5_MASK;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that :(
Fixed in the last revision.
Mozc doesn't know Super and other extra modifier keys except for Alt. For example, "Super + Space" (IBus' default for switching input methods) is recognized as "Space". This change ignores key events that have these extra modifiers to let others handle the events. Fixes google#853.
We have merged your PR. |
2.30.5595 → 2.30.5618 Conversion * Updated zip code entries (#1063). * Updated word entries (#1068, #1069) Bug fix * Linux: Enabled switching to the DIRECT mode from the menu (#1061) * Linux: Enabled switching modes with Super+Space in Wayland (#853, #1059) * macOS: Fixed the limitation of mouse clicking on the renderer on macOS 15 (120bd93) * Windows: Fixed the setting of Omaha updater for the GoogleJapaneseInput build (#1072) Build * Android: Switched the Bazel rules from WORKSPACE to Bzlmod (#1002) * Android: Updated the Docker build environment * Linux: Update the build environment: Ubuntu 22.04 → 24.04 (#924) * macOS / Windows: Updated the Qt version: 6.7.2 → 6.7.3 (#1065) * Windows: Supported Bazel build (#948) * Windows: Updated the Wix version: 4.0.5 → 5.0.2 (#1070) Code * Performed code refactoring PiperOrigin-RevId: 684295272
Description
Mozc doesn't know Super and other extra modifier keys except for Alt. For example, "Super + Space" (IBus' default for switching input methods) is recognized as "Space".
This change ignores key events that have these extra modifiers to let others handle the events.
Issue IDs
#853
Steps to test new behaviors (if any)
A clear and concise description about how to verify new behaviors (if any).
Additional context
Add any other context about the pull request here.