File tree Expand file tree Collapse file tree 3 files changed +57
-3
lines changed Expand file tree Collapse file tree 3 files changed +57
-3
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,27 @@ bool InputContext::hasPendingEvents() const {
329329 return !d->blockedEvents_ .empty ();
330330}
331331
332+ bool InputContext::hasPendingEventsStrictOrder () const {
333+ FCITX_D ();
334+ if (d->blockedEvents_ .empty ()) {
335+ return false ;
336+ }
337+
338+ // Check we only have update preedit.
339+ if (std::any_of (d->blockedEvents_ .begin (), d->blockedEvents_ .end (),
340+ [](const auto &event) {
341+ return event->type () !=
342+ EventType::InputContextUpdatePreedit;
343+ })) {
344+ return false ;
345+ }
346+
347+ // Check whether the preedit is non-empty.
348+ // If key event may produce anything, it still may trigger the clear
349+ // preedit. In that case, preedit order does matter.
350+ return !inputPanel ().clientPreedit ().toString ().empty ();
351+ }
352+
332353void InputContext::commitString (const std::string &text) {
333354 FCITX_D ();
334355 if (auto *instance = d->manager_ .instance ()) {
@@ -367,11 +388,21 @@ InputPanel &InputContext::inputPanel() {
367388 return d->inputPanel_ ;
368389}
369390
391+ const InputPanel &InputContext::inputPanel () const {
392+ FCITX_D ();
393+ return d->inputPanel_ ;
394+ }
395+
370396StatusArea &InputContext::statusArea () {
371397 FCITX_D ();
372398 return d->statusArea_ ;
373399}
374400
401+ const StatusArea &InputContext::statusArea () const {
402+ FCITX_D ();
403+ return d->statusArea_ ;
404+ }
405+
375406void InputContext::updateClientSideUIImpl () {}
376407
377408InputContextEventBlocker::InputContextEventBlocker (InputContext *inputContext)
Original file line number Diff line number Diff line change @@ -207,6 +207,16 @@ class FCITXCORE_EXPORT InputContext : public TrackableObject<InputContext> {
207207 void setBlockEventToClient (bool block);
208208 bool hasPendingEvents () const ;
209209
210+ /* *
211+ * Has pending event that need to use key order fix.
212+ *
213+ * If pending event only have preedit, then it's generally fine to not use
214+ * key forward.
215+ *
216+ * @since 5.0.21
217+ */
218+ bool hasPendingEventsStrictOrder () const ;
219+
210220 // / Returns the input context property by name.
211221 InputContextProperty *property (const std::string &name);
212222
@@ -216,9 +226,23 @@ class FCITXCORE_EXPORT InputContext : public TrackableObject<InputContext> {
216226 // / Returns the associated input panel.
217227 InputPanel &inputPanel ();
218228
229+ /* *
230+ * Returns the associated input panel.
231+ *
232+ * @since 5.0.22
233+ */
234+ const InputPanel &inputPanel () const ;
235+
219236 // / Returns the associated StatusArea.
220237 StatusArea &statusArea ();
221238
239+ /* *
240+ * Returns the associated StatusArea.
241+ *
242+ * @since 5.0.22
243+ */
244+ const StatusArea &statusArea () const ;
245+
222246 /* *
223247 * Helper function to return the input context property in specific type.
224248 *
Original file line number Diff line number Diff line change @@ -1443,9 +1443,8 @@ bool Instance::postEvent(Event &event) const {
14431443 : XKB_KEY_DOWN);
14441444 } while (0 );
14451445#endif
1446- if (ic->hasPendingEvents () &&
1447- ic->capabilityFlags ().test (CapabilityFlag::KeyEventOrderFix) &&
1448- !keyEvent.accepted ()) {
1446+ if (ic->capabilityFlags ().test (CapabilityFlag::KeyEventOrderFix) &&
1447+ !keyEvent.accepted () && ic->hasPendingEventsStrictOrder ()) {
14491448 // Re-forward the event to ensure we got delivered later than
14501449 // commit.
14511450 keyEvent.filterAndAccept ();
You can’t perform that action at this time.
0 commit comments