Skip to content
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

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/unix/ibus/key_event_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ bool KeyEventHandler::GetKeyEvent(uint keyval, uint keycode, uint modifiers,
DCHECK(key);
key->Clear();

// Ignore key events with modifiers, except for the below;
// - Alt (Mod1) - Mozc uses Alt for shortcuts
// - NumLock (Mod2) - NumLock shouldn't impact shortcuts
// This is needed for handling shortcuts such as Super (Mod4) + Space,
// IBus's default for switching input methods.
// https://github.com/google/mozc/issues/853
constexpr uint kExtraModMask =
IBUS_MOD3_MASK | IBUS_MOD4_MASK | IBUS_MOD5_MASK;
if (modifiers & kExtraModMask) {
return false;
}

if (!key_translator_->Translate(keyval, keycode, modifiers, preedit_method,
layout_is_jp, key)) {
LOG(ERROR) << "Translate failed";
Expand Down
7 changes: 7 additions & 0 deletions src/unix/ibus/key_event_handler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ TEST_F(KeyEventHandlerTest, GetKeyEvent) {
EXPECT_NO_MODIFIERS_PRESSED();
}

{ // Ignore Super (Mod4)
key.Clear();
EXPECT_FALSE(handler_->GetKeyEvent(IBUS_space, kDummyKeycode,
IBUS_MOD4_MASK, config::Config::ROMAN,
true, &key));
}

// This test fails in current implementation.
// TODO(hsumita): Enables it.
/*
Expand Down