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

Implement Wayland xcb layout options #712

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions src/lib/fcitx/inputmethodconfig_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ FCITX_CONFIGURATION(
Option<std::vector<InputMethodGroupItemConfig>> items{this, "Items",
"Items"};
Option<std::string> defaultLayout{this, "Default Layout", "Layout"};
Option<std::string> defaultLayoutOptions{this, "Default Layout Options", "XKB Layout Options"};
Option<std::string> defaultInputMethod{this, "DefaultIM",
"Default Input Method"};);

Expand Down
12 changes: 12 additions & 0 deletions src/lib/fcitx/inputmethodgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class InputMethodGroupPrivate {
std::vector<InputMethodGroupItem> inputMethodList_;
std::string defaultInputMethod_;
std::string defaultLayout_;
std::string defaultLayoutOptions_;
};

InputMethodGroupItem::InputMethodGroupItem(const std::string &name)
Expand Down Expand Up @@ -132,4 +133,15 @@ const std::string &InputMethodGroup::defaultLayout() const {
FCITX_D();
return d->defaultLayout_;
}

void InputMethodGroup::setDefaultLayoutOptions(
const std::string &layoutOptions) {
FCITX_D();
d->defaultLayoutOptions_ = layoutOptions;
}

const std::string &InputMethodGroup::defaultLayoutOptions() const {
FCITX_D();
return d->defaultLayoutOptions_;
}
} // namespace fcitx
2 changes: 2 additions & 0 deletions src/lib/fcitx/inputmethodgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class FCITXCORE_EXPORT InputMethodGroup {
const std::string &name() const;
void setDefaultLayout(const std::string &layout);
const std::string &defaultLayout() const;
void setDefaultLayoutOptions(const std::string &layoutOptions);
const std::string &defaultLayoutOptions() const;
std::vector<InputMethodGroupItem> &inputMethodList();
const std::vector<InputMethodGroupItem> &inputMethodList() const;
const std::string &defaultInputMethod() const;
Expand Down
3 changes: 3 additions & 0 deletions src/lib/fcitx/inputmethodmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ void InputMethodManagerPrivate::loadConfig(
tempOrder.push_back(groupConfig.name.value());
auto &group = result.first->second;
group.setDefaultLayout(groupConfig.defaultLayout.value());
group.setDefaultLayoutOptions(
groupConfig.defaultLayoutOptions.value());
const auto &items = groupConfig.items.value();
for (const auto &item : items) {
if (!entries_.count(item.name.value())) {
Expand Down Expand Up @@ -406,6 +408,7 @@ void InputMethodManager::save() {
auto &groupConfig = groups.back();
groupConfig.name.setValue(group.name());
groupConfig.defaultLayout.setValue(group.defaultLayout());
groupConfig.defaultLayoutOptions.setValue(group.defaultLayoutOptions());
groupConfig.defaultInputMethod.setValue(group.defaultInputMethod());
std::vector<InputMethodGroupItemConfig> itemsConfig;
for (auto &item : group.inputMethodList()) {
Expand Down
6 changes: 4 additions & 2 deletions src/modules/wayland/waylandmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ WaylandModule::WaylandModule(fcitx::Instance *instance)
return;
}

auto layoutAndVariant = parseLayout(
instance_->inputMethodManager().currentGroup().defaultLayout());
auto group = instance_->inputMethodManager().currentGroup();
auto layoutAndVariant = parseLayout(group.defaultLayout());

if (layoutAndVariant.first.empty()) {
return;
Expand All @@ -213,6 +213,8 @@ WaylandModule::WaylandModule(fcitx::Instance *instance)
config.setValueByPath("Layout/LayoutList", layoutAndVariant.first);
config.setValueByPath("Layout/VariantList",
layoutAndVariant.second);
config.setValueByPath("Layout/Options",
group.defaultLayoutOptions());
config.setValueByPath("Layout/DisplayNames", "");
config.setValueByPath("Layout/Use", "true");

Expand Down