15 Commits

Author SHA1 Message Date
William Wold
bc45d04f4b
Set the IM context when showing the input method (#21896) 2020-11-06 09:22:17 +13:00
J-P Nurmi
bb32446c68
Fix FlTextInputPlugin tear down (#22007) 2020-10-29 15:18:04 -07:00
Chris Bracken
bcc557f1ba
Add multi-step input method support for Linux (#21897)
This implements the Gtk hooks required to support multi-step input
methods on Linux. This builds on the support for composing regions
(preedit region in Gtk terminology) added to TextInputModel in
https://github.com/flutter/engine/pull/21682.

Specifically, the following changes are included:

1. Add handler for TextInput.setMarkedTextRegion framework messages: On
any change to the EditableText in the framework, this message is sent
which provides an updated rect (in the local co-ordinates of the
EditableText) for the composing region. If not in composing mode, the
cursor rect is sent.

2. Add handler for TextInput.setEditableSizeAndTransform framework messages:
On any change to the RenderObject underlying the EditableText, an
updated size for the full EditableText widget, as well as an affine
transform matrix from local co-ordinates to Flutter root co-ordinates is
sent.

3. On either of the above messages, we use the transformed composing
rect to compute the cursor position in Gtk window co-ordinates and
inform Gtk, so that it can position any system IM composing window
correctly for on-the-spot composing, such as is used when inputting
Japanese text.

4. Adds handlers for preedit-start, preedit-changed, and preedit-end
signals from Gtk. These are passed on to the TextInputModel.

5. Updates the preedit-commit handler to commit the composing region to
the text or, if not composing, insert new text at the cursor.

6. Updates the handler for TextInput.setEditingState framework messages
to extract the composing range base and extent and pass these on to
TextInputModel.

7. Updates update_editing_state function to set composing base and
extent on text input state updates sent to the framework.
2020-10-19 16:25:56 -07:00
J-P Nurmi
9946be45a9
FlTextInputPlugin: fix memory leaks (#21879)
This PR fixes a few small memory leaks in FlTextInputPlugin. All three cases
are creating temporary FlValue instances for lookups and comparison without
ever releasing them.
2020-10-19 16:23:10 -07:00
Chris Bracken
b715d3f21d
Migrate TextInputPlugin API to TextRange (#21854)
Replaces selection_base() and selection_extent() with selection() and
SetSelection(int, int) with SetSelection(range).

This also adds the following convenience methods to TextRange:
* reversed()
* Contains(size_t position)
* Contains(const TextRange& range)

as well as operator== for use in unit tests. When Flutter migrates to
C++20, we can replace that method with a default declaration.
2020-10-15 09:54:06 -07:00
Chris Bracken
7e6191de07
Separate mutators for text and selection (#21612)
Previously, TextInputModel's SetEditingState method was a 1:1 mapping of
the underlying protocol used on the text input channel between the
framework and the engine. This breaks it up into two methods, which
allows the selection to be updated independently of the text, and avoids
tying the API the the underlying protocol.

This will become more important when we add additional state to support
composing regions for multi-step input methods such as those used for
Japanese.

SetText resets the selection rather than making a best-efforts attempt
to preserve it. This choice was primarily to keep the code simple and
make the API easier to reason about. An alternative would have been to
make a best-effort attempt to preserve the selection, potentially
clamping one or both to the end of the new string. In all cases where an
embedder resets the string, it is expected that they also have the
selection, so can call SetSelection with an updated selection if needed.
2020-10-06 11:07:21 -07:00
Maksim Lin
57fdf0a1fb
send newline char when input type is multiline (#20660) 2020-08-25 10:51:02 -07:00
Robert Ancell
ab23dc3a74 Update code style to pass clang-tidy checks 2020-08-05 10:35:03 +12:00
stuartmorgan
29f63349c8
Fix invalid selection handling in text plugins (#19899)
The Windows, Linux, and GLFW embeddings (which all share a common code
ancestry) pass TextInput.setEditingState selection base and extents
straight through to the shared text model class. The model expects those
values to be valid, but the framework sends -1/-1 for "invalid"
selections, which happen for some empty text cases (e.g.,
TextFieldController.clear()).

This translates those invalid selection values to an empty selection at
the start of the string, as expected by the model.

Fixes https://github.com/flutter/flutter/issues/59140
2020-07-27 11:00:02 -07:00
Robert Ancell
9f898e98c2
Don't process key events when the text input is not requested (#18990) 2020-06-12 10:59:35 +12:00
Robert Ancell
6f5d92d241
Remove the input type and action from TextInputModel. (#18919)
These aren't used by the model so are better managed outside of it.
2020-06-10 10:00:32 +12:00
Robert Ancell
db6793bca3
Use constant for error code (#18913) 2020-06-10 06:27:08 +12:00
Robert Ancell
320e80552f
Update FlTextInputPlugin method handler style. (#18886)
Match the style used in the external plugins and more carefully vet the incoming
arguments.
2020-06-09 11:36:00 +12:00
Robert Ancell
8d97830992
Fix braces style (#18837) 2020-06-05 13:26:54 +12:00
Robert Ancell
2bd95d9a4c
Add FlTextInputPlugin (#18314)
* Add FlTextInputPlugin
2020-05-28 13:11:16 +12:00