Skip to content

Commit

Permalink
fix old focus out after new focus in; reset display mode
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Jan 25, 2025
1 parent f517c26 commit 240cb47
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion engines/fcitx5-rime
2 changes: 1 addition & 1 deletion engines/libime
7 changes: 6 additions & 1 deletion iosfrontend/iosfrontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ void IosFrontend::focusIn(id client) {
ic_->focusIn();
}

void IosFrontend::focusOut() {
void IosFrontend::focusOut(id client) {
// Old viewWillDisappear may be called after new viewWillAppear (if
// switching apps) so don't always reset.
if (client != ic_->getClient()) {
return;
}
ic_->focusOut();
// Extracting client from nil crashes on Swift, so it has to be put after
// ic_->focusOut, although commit on focus out doesn't work on iOS (even if
Expand Down
2 changes: 1 addition & 1 deletion iosfrontend/iosfrontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IosFrontend : public AddonInstance {
void createInputContext();
bool keyEvent(const Key &key, bool isRelease);
void focusIn(id client);
void focusOut();
void focusOut(id client);

private:
Instance *instance_;
Expand Down
3 changes: 2 additions & 1 deletion keyboard/KeyboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ class KeyboardViewController: UIInputViewController, FcitxProtocol {
logger.info("Reload accepted")
reload()
}
virtualKeyboardView.setDisplayMode(.initial)
focusIn(self)
}

override func viewWillDisappear(_ animated: Bool) {
logger.info("viewWillDisappear \(self.id)")
super.viewWillDisappear(animated)
focusOut()
focusOut(self)
}

deinit {
Expand Down
4 changes: 2 additions & 2 deletions keyboard/fcitx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ void focusIn(id client) {
return with_fcitx([client] { frontend->focusIn(client); });
}

void focusOut() {
return with_fcitx([] { frontend->focusOut(); });
void focusOut(id client) {
return with_fcitx([client] { frontend->focusOut(client); });
}

bool processKey(const char *key) {
Expand Down
2 changes: 1 addition & 1 deletion keyboard/fcitx.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

void startFcitx(const char *bundlePath, const char *appGroupPath);
void focusIn(id client);
void focusOut();
void focusOut(id client);
bool processKey(const char *key);
void reload();

0 comments on commit 240cb47

Please sign in to comment.