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

fix Shift+Tab normalized to Tab #1132

Merged
merged 2 commits into from
Sep 13, 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: 7 additions & 5 deletions src/lib/fcitx-utils/key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ bool Key::isVirtual() const { return states_.test(KeyState::Virtual); }

Key Key::normalize() const {
Key key(*this);

if (key.sym_ == FcitxKey_ISO_Left_Tab) {
key.sym_ = FcitxKey_Tab;
}

/* key state != 0 */
key.states_ =
key.states_ & KeyStates({KeyState::Ctrl_Alt_Shift, KeyState::Super,
Expand All @@ -495,17 +500,14 @@ Key Key::normalize() const {
if ((key.states_ & KeyState::Shift) &&
(((Key(key.sym_).isSimple() ||
keySymToUnicode(key.sym_) != 0) &&
key.sym_ != FcitxKey_space && key.sym_ != FcitxKey_Return) ||
key.sym_ != FcitxKey_space && key.sym_ != FcitxKey_Return &&
key.sym_ != FcitxKey_Tab) ||
(key.sym_ >= FcitxKey_KP_0 && key.sym_ <= FcitxKey_KP_9))) {
key.states_ ^= KeyState::Shift;
}
}
}

if (key.sym_ == FcitxKey_ISO_Left_Tab) {
key.sym_ = FcitxKey_Tab;
}

return key;
}

Expand Down
6 changes: 6 additions & 0 deletions test/testkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ int main() {
FCITX_ASSERT(fcitx::Key("S").check(fcitx::Key("Shift+S").normalize()));
FCITX_ASSERT(
fcitx::Key("Shift+F4").check(fcitx::Key("Shift+F4").normalize()));
FCITX_ASSERT(
fcitx::Key("Shift+Tab").check(fcitx::Key("Shift+Tab").normalize()));
FCITX_ASSERT(fcitx::Key("Shift+Return")
.check(fcitx::Key("Shift+Return").normalize()));
FCITX_ASSERT(
fcitx::Key("Shift+space").check(fcitx::Key("Shift+space").normalize()));
FCITX_ASSERT(
fcitx::Key("Control+A").check(fcitx::Key("Control+a").normalize()));
FCITX_ASSERT(fcitx::Key("Alt+exclam")
Expand Down
Loading