Skip to content
Open
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
17 changes: 17 additions & 0 deletions src/lib/fcitx/globalconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ FCITX_CONFIGURATION(
{Key("Hangul_Romaja")},
KeyListConstrain({KeyConstrainFlag::AllowModifierLess,
KeyConstrainFlag::AllowModifierOnly})};
OptionWithAnnotation<bool, ToolTipAnnotation> consumeRedundantActivateKeys{{
.parent = this,
.path{"ConsumeRedundantActivateKeys"},
.description{_("Consume redundant Activate/Deactivate key")},
.defaultValue = false,
.annotation{
_("When the input method is already in the state the key "
"requests, pressing an Activate/Deactivate key changes "
"nothing; consume the key event in that case instead of "
"forwarding it to the application. Modifier only keys are "
"never consumed.")},
}};
KeyListOptionWithAnnotation<ToolTipAnnotation> altTriggerKeys{
{.parent = this,
.path{"AltTriggerKeys"},
Expand Down Expand Up @@ -298,6 +310,11 @@ const KeyList &GlobalConfig::deactivateKeys() const {
return d->hotkey->deactivateKeys.value();
}

bool GlobalConfig::consumeRedundantActivateKeys() const {
FCITX_D();
return *d->hotkey->consumeRedundantActivateKeys;
}

const KeyList &GlobalConfig::enumerateForwardKeys() const {
FCITX_D();
return d->hotkey->enumerateForwardKeys.value();
Expand Down
13 changes: 13 additions & 0 deletions src/lib/fcitx/globalconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ class FCITXCORE_EXPORT GlobalConfig {
const KeyList &altTriggerKeys() const;
const KeyList &activateKeys() const;
const KeyList &deactivateKeys() const;

/**
* Consume Activate/Deactivate keys even when the state does not change.
*
* When enabled, pressing an activate key while the input method is
* already active (or a deactivate key while inactive) is consumed by
* fcitx instead of being forwarded to the application. Modifier only
* keys are not affected.
*
* @return whether to consume redundant activate/deactivate keys
* @since 5.1.22
*/
bool consumeRedundantActivateKeys() const;
const KeyList &enumerateForwardKeys() const;
const KeyList &enumerateBackwardKeys() const;
bool enumerateSkipFirst() const;
Expand Down
6 changes: 4 additions & 2 deletions src/lib/fcitx/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ bool InstancePrivate::canActivate(InputContext *ic) {
return false;
}
auto *inputState = ic->propertyFor(&inputStateFactory_);
return !inputState->isActive();
return (!inputState->isActive()) ||
globalConfig_.consumeRedundantActivateKeys();
}

bool InstancePrivate::canDeactivate(InputContext *ic) {
Expand All @@ -466,7 +467,8 @@ bool InstancePrivate::canDeactivate(InputContext *ic) {
return false;
}
auto *inputState = ic->propertyFor(&inputStateFactory_);
return inputState->isActive();
return inputState->isActive() ||
globalConfig_.consumeRedundantActivateKeys();
}

void InstancePrivate::navigateGroup(InputContext *ic, const Key &key,
Expand Down