Skip to content

Commit a2d4b03

Browse files
sophiel-meowwengxt
authored andcommitted
[wayland] Refactor layout diversity check using std::optional
1 parent 6a00cb6 commit a2d4b03

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/modules/wayland/waylandmodule.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -746,23 +746,27 @@ void WaylandModule::selfDiagnose() {
746746

747747
// layout diagnosis only when overriding is enabled
748748
if (*config_.allowOverrideXKB) {
749-
std::unordered_set<std::string> groupLayouts;
749+
std::optional<std::string> firstLayout;
750750
for (const auto &groupName :
751751
instance_->inputMethodManager().groups()) {
752752
if (const auto *group =
753753
instance_->inputMethodManager().group(groupName)) {
754-
groupLayouts.insert(group->defaultLayout());
755-
}
756-
if (groupLayouts.size() >= 2) {
757-
messages.push_back(
758-
_("Sending keyboard layout configuration to wayland "
759-
"compositor from Fcitx is "
760-
"not yet supported on current desktop. You may still "
761-
"use "
762-
"Fcitx's internal layout conversion by adding layout "
763-
"as "
764-
"input method to the input method group."));
765-
break;
754+
const auto &layout = group->defaultLayout();
755+
if (!firstLayout) {
756+
firstLayout = layout;
757+
} else if (layout != *firstLayout) {
758+
messages.push_back(_(
759+
"Sending keyboard layout configuration to wayland "
760+
"compositor from Fcitx is "
761+
"not yet supported on current desktop. You may "
762+
"still "
763+
"use "
764+
"Fcitx's internal layout conversion by adding "
765+
"layout "
766+
"as "
767+
"input method to the input method group."));
768+
break;
769+
}
766770
}
767771
}
768772
}

0 commit comments

Comments
 (0)